List Info

Thread: Object>>#do: ???




Object>>#do: ???
country flaguser name
Italy
2007-06-06 00:12:56
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?

Paolo



_______________________________________________
help-smalltalk mailing list
help-smalltalkgnu.org

http://lists.gnu.org/mailman/listinfo/help-smalltalk

Re: Object>>#do: ???
country flaguser name
United States
2007-06-06 00:38:28
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.no
candysw.com/blog **
Failure to imagine vast possibilities usually stems from a
lack of
imagination, not a lack of possibility.

_______________________________________________
help-smalltalk mailing list
help-smalltalkgnu.org

http://lists.gnu.org/mailman/listinfo/help-smalltalk

Re: Object>>#do: ???
country flaguser name
United States
2007-06-06 01:23:13
On Wed, 2007-06-06 at 00:38 -0500, Stephen Compall wrote:
> Very.  I got a distinctly bad taste in my figurative
mouth when I saw it
> in RBProgramNode.

I was going to add more prose here to explain this further,
but perhaps
this is better.  This is what goes through my head:

Object extend [
    basicDoesNotUnderstand: aMessage [
        <primitive: VMpr_Object_bootstrapDNU>
    ]

    doesNotUnderstand: aMessage [
        ^(Array canUnderstand: aMessage selector)
            ifTrue: [aMessage sendTo: ]
            ifFalse: [self basicDoesNotUnderstand:
aMessage]
    ]
]

Array extend [
    doesNotUnderstand: aMessage [
        ^self basicDoesNotUnderstand: aMessage
    ]
]

-- 
;;; Stephen Compall ** http://scompall.no
candysw.com/blog **
Failure to imagine vast possibilities usually stems from a
lack of
imagination, not a lack of possibility.

_______________________________________________
help-smalltalk mailing list
help-smalltalkgnu.org

http://lists.gnu.org/mailman/listinfo/help-smalltalk

Re: Object>>#do: ???
country flaguser name
United States
2007-06-06 12:23:29
On Wed, 2007-06-06 at 16:54 +0200, Paolo Bonzini wrote:
> You did realize that this is also subsuming
> 
>      do: aBlock [ aBlock value: self ]
> 
> didn't you? :-P

Indeed, it is the ultimate reduction of the principle
initially
presented by Object>>#do:.

Though one might moreover expect

| arrayResult |
arrayResult := aMessage sendTo: .
(arrayResult isArray and: [arrayResult size = 1])
    ifTrue: [arrayResult first]
    ifFalse: [arrayResult]

-- 
;;; Stephen Compall ** http://scompall.no
candysw.com/blog **
Failure to imagine vast possibilities usually stems from a
lack of
imagination, not a lack of possibility.

_______________________________________________
help-smalltalk mailing list
help-smalltalkgnu.org

http://lists.gnu.org/mailman/listinfo/help-smalltalk

[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )