(#(nil) at: 1) ~~ nil
Marcus Denker
marcus at ira.uka.de
Mon Feb 8 16:30:24 UTC 1999
On Mon, Feb 08, 1999 at 07:47:56AM -0600, Dave Newman wrote:
> In furthering my understanding of Squeak I came across the fact
> that
>
> ( #( nil ) at: 1 ) ~~ nil.
>
> evaluates to true.
>
Yes. You can see how this is parsed by squeak in Scanner>>xLitQuote.
and than Scanner>>scanLitVec.
Squeak only recognizes Integers, Floats, $characters, #symbols ,'strings'
and #(arrays itself) inside a #( ). # is optional, so every string without
' ' is automatically a #symbol. The # is even optional for #(arrays), so
you can write:
#(1 (2 (3 (4 (5 ('hey , really LISPy !'))))))
So... this is how it was implemented. But why? Somehow I think that
the whole #( ) syntax is a bit strange.
e.g (#(0.2) at: 1) is 0.2 , but (#(1/5) at: 1) evaluates to 1. :-(
With the new 2.3 coercion-features we can get the following results:
(#(1 3) * 1/4) * 4 is (1 3 ), but:
#(1 3) * 1/4 --> ((1/4) (3/4) )
#((1/4) (3/4) ) * 4 --> ((4 0 16 ) (12 0 16 ) )
A "correct" interpretation would require the evaluation of
expressions inside a literal array.
Marcus
--
Marcus Denker marcus at ira.uka.de fon at home:(0721)614235 @work:(0721)608-2749
Smalltalkers do: [:it | All with: Class, (And love: it)]
More information about the Squeak-dev
mailing list
|