[ANSI-Smalltalk] Protocol extensions - Object

Peter van Rooijen peter at vanrooijen.com
Mon Sep 8 19:57:00 BST 2008


On Mon, 08 Sep 2008 09:21:32 +0200, Paolo Bonzini <bonzini at gnu.org> wrote:

> Richard A. O'Keefe wrote:
>> On 8 Sep 2008, at 6:04 pm, Paolo Bonzini wrote:
>>> Squeak overloads #perform: for a Message argument, see
>>>
>>> http://lists.squeakfoundation.org/pipermail/squeak-dev/2007-September/120697.html
>>>
>>>
>>> for an example.  What do you think about it?
>>
>> I think I can't find it in Squeak 3.10.
>
> I don't know -- the page I cited has
>
> RadioWrapper class >> doesNotUnderstand: aMessage
> 	"Handle messages that are not implemented on this wrapper by
> 	 passing them to #subject"
> 	^self subject class perform: aMessage.
>
> I looked in my notes and found that Dolphin was the one which originally
> introduced this extension.
>
>> What Squeak _does_ have is Message sentTo: anObject,
>> so
>>     (Message selector: #+ argument: 2) sentTo: 1
>>
>> works.  Adding Message>>sentTo: does not raise that question.
>> It does seem odd to have Messages with no direct way to send
>> them, so adding #sentTo: would seem to make sense.
>
> Yes.  However, I'm reluctant on the naming.  Why #sentTo: and not
> #sendTo:?

Paolo, just accept that Squeak is weird ;-).

> I've almost never seen a method named as a past participle,
> and when I did, it returned a variation of the receiver, for example
> #reversed or #sorted.

Uhh, isn't that #reverse (not #reversed)? From ST-98:

Answer a collection conforming to the same protocols as the receiver, but  
with its elements
arranged in reverse order.
This operation is equivalent to:
1. Create a new collection which conforms to the same protocols as the  
receiver;
2. Traverse the elements of the receiver in the order specified by the  
#reverseDo: message,
adding each element of the receiver to the new collection;
3. Answer the new collection.

So it returns a copy, not the receiver, which makes you wonder why it  
isn't called #reversed.

BTW this description is also flawed because the receiver is not guaranteed  
to be extensible, oh well...

I suppose these things are important in a way. I certainly have to  
remember that it's called #reverse, not #reversed as a separate bit of  
information, which is undesired cognitive overhead.

Peter

> Paolo
>
> _______________________________________________
> ANSI-Smalltalk mailing list
> ANSI-Smalltalk at lists.openskills.org
> http://lists.openskills.org/cgi-bin/mailman/listinfo/ansi-smalltalk
>



-- 
Peter van Rooijen
Esstede 19
1112 EP Diemen
m: 06-2854 2048



More information about the ANSI-Smalltalk mailing list