[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-smalltalk] Object>>#do: ???
From: |
Stephen Compall |
Subject: |
Re: [Help-smalltalk] Object>>#do: ??? |
Date: |
Wed, 06 Jun 2007 00:38:28 -0500 |
On Wed, 2007-06-06 at 07:12 +0200, Paolo Bonzini wrote:
> Stephen's idea and my answer regarding #flatten: gave me a weird idea.
> Adding
>
> Object >> do: aBlock [ aBlock value: self ]
>
> would be quite convenient in many cases where you have double dispatch
> going on between normal objects and collections. How weird would this be?
Very. I got a distinctly bad taste in my figurative mouth when I saw it
in RBProgramNode.
I actually would rather that #flatten (or whatever it's called) not
conflate non-collections with collections so that
#((1 2) 3) flatten
signals an error.
On the other hand, something like the CL utility seen in some places
(defun mklist (obj)
(if (listp obj)
obj
(list obj)))
might be a good solution for those cases, since it makes it absolutely
clear that the code wishes to conflate collections and non-collections.
Something other than #asArray, of course :)
--
;;; Stephen Compall ** http://scompall.nocandysw.com/blog **
Failure to imagine vast possibilities usually stems from a lack of
imagination, not a lack of possibility.
signature.asc
Description: This is a digitally signed message part