Incongruent hash

Tim Olson tim at jumpnet.com
Sun Feb 15 15:00:42 UTC 1998


David N. Smith wrote:

>A 'simple' notation occurs to me, and it is not a proposal but a discussion
>item, where a class name is followed by expressions in curly brackets:
>
>   Array{a. b. c}        is equivalent to {a. b. c}
>   Set{a. b. c}          is equivalent to (Set with: a with: b with: c)
>
>Then, either of:
>
>   Vector{x. y. z}       which is equivalent to (Vector   x: x y: y z: z)
>   Vector3D{x. y. z}     which is equivalent to (Vector3D x: x y: y z: z)
>
>could produce a vector with 3 coordinates. (I'm assuming there is an
>abstract parent class named Vector, of course.)


The Squeak compiler already supports this with the "as:" notation, e.g.:

     {a. b. c} as: Set

This is one of the Macro Transformations that is performed at 
compile-time, so the value is constructed directly as a Set, rather than 
being constructed as a temporary Array which is then used to construct 
the set.

>There are three problems with this that I see offhand:
>
>* It requires a compiler change.

Not if you use the existing notation ;-)


>* It doesn't well support classes that aren't collection-like.
>
>Then there is the question of the protocol the compiler uses to create such
>objects. It would have to ask the class for the name of a class method
>which can be sent with n items:

All that is required is that the class implement the class method 
"fromBraceStack: size".




     -- tim





More information about the Squeak-dev mailing list