Stephen Compall wrote:
> On Fri, 2007-03-23 at 15:26 +0100, Paolo Bonzini wrote:
>> One possibility could be to extend the {...} syntax to something
>> like "OrderedCollection {...}", "Dictionary {...}", and have it send
>> messages like "#braceWithAll:".  Then you would have:
> 
> I would rather leave the syntax alone and just add the protocol:

What about adding #from: ?  I want it to be terse and still clear if
possible.

>>      Dictionary >> braceWithAll: x
>>          | dict |
>>          dict := self new: x size * 2.
> 
> I like these as they are, except for the * 2 in Dictionary's method.

Well, it's there because a hash table needs more room than it has
elements.  In fact I'm about to add

     HashedCollection >> withAll: x
         | result |
         result := self new: x size * 2.
         result addAll: x.
         ^result

It does not apply to with:with: and friends only because of

new: anInteger
    "Answer a new instance of the receiver with the given size"
    | realSize |
    realSize := 8 max: anInteger.
    ...
    ^(self primNew: realSize) initialize: realSize

Paolo


_______________________________________________
help-smalltalk mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-smalltalk

Reply via email to