Polymorphism without protocol dilution

Mike Klein mike at twinsun.com
Tue Sep 1 23:36:04 UTC 1998


Dave wrote:

> #at:ifAbsentPut:, as proposed, would allow a block and evaluate its
> contents before putting the result into the collection. However, this
> prevents actually putting a block into the collection without an ugly
> contortion:
> 
>    dict at: aKey ifAbsentPut: [ [ blockCode ] ]

Personally I find this rather natural.  I guess beauty is in the eye of
the beholder.

> #at:ifAbsentPutValueOf: makes this explicit. One is not putting the block
> into the collection, but the result of evaluating the block.
> 
> 
> Note that, for consistancy, if the thrid example is considered wrong, one
> should then make #at:put: have the same properties as #at:ifAbsentPut:. If
> a block is passed it is evaluated before putting its value into the
> collection.

Perhaps #ifTrue:ifFalse: should be renamed to
#ifTrueValueOf:ifFalseValueOf:  and likewise for all of the other
"control" methods.  Just kidding.

I expect a niladicValuable (in X3J20-speak) when I see the fragment

   ifAbsent:

so I also expect ifAbsentPut: to take one.

-- Mike Klein





More information about the Squeak-dev mailing list