nil or #nil?

Pat Caudill patc at teleport.com
Sun Aug 23 17:43:23 UTC 1998


>>Table _ #( (-1 -1 ) 2 3 nil).
>>
>>Apparently, the Smalltalk that T-Gen was written for (?) treats nil as a
>>special case. But for Squeak, (Table at: 4) == #nil (not nil). This was
>>pretty tricky since it looks like a nil when you print it out. If you
>>inspect it, however, you see that it is an array with three elements.
>>
>>I'm thinking that this is so confusing that Squeak should adopt the
>>behavior of recognizing 'nil' as a special case inside of a constant array.

>I think it is correct the way it is in Squeak -- literal vectors are 
>built from unevaluated literals, where all literals are "self-evaluating" 
>(evaluate to themselves).  The value of the symbol nil is the symbol nil, 
>which is different from the standard value nil (the sole instance of 
>UndefinedObject).
>
>Making a special case for nil here starts one down the slippery slope of 
>mixing up symbols and variables (values).  What about #true and #false -- 
>would you expect them to exist in the literal vector as symbols or 
>Booleans?  What about symbols which match existing entries in the 
>SystemDictionary, such as classes?


Well I am looking at an older copy of the document, not the approved one, 
but the ANSI standard states "If an identifier appears as an <array 
element> and it is one of the reserved identifiers nil, true, false the 
value of the coresponding element of the collection is the value of that 
identifier." If you want the symbol nil you say 
Table _ #( (-1 -1 ) 2 3 #nil).

Pat Caudill
patc at acm.org





More information about the Squeak-dev mailing list