nil, true, false in literal arrays
Richard A. O'Keefe
ok at cs.otago.ac.nz
Tue Feb 17 04:55:22 UTC 2004
Avi Bryant <avi at beta4.com> mentioned #(nil true false)
Anyone know offhand what ANSI dictates here?
184.108.40.206 Array Literals
An array literal is a sequenced collection with numeric keys which may
contain any number of other literals.
<array literal> ::= '#(' <array element>* ')'
<array element> ::= <literal> | identifier
If an identifier appeasr as an <array element> and it is one of
the reserved identifiers nil, true or false the value of the
corresponding element of the collection is the value of that
reserved identifier. The meaning is UNDEFINED if any other identifier
is used as an <array element>.
<literal> ::= <number literal> "[-]number"
| <string literal> "'...''...'"
| <character literal> "$char"
| <symbol literal> "#'string'"
| <selector literal> "#selector"
| <array literal>
So according to ANSI,
#(nil true false) contains a nil and two Booleans
#(Nil True False) is is undefined, it need not have three elements,
it need not even be a sequence.
#(#'nil' #'true' #'false') contains three <symbol>s
#(#nil #true #false) contains three selectors, which may well not
be <symbols>, but then again, might be.
#((1 2) (3 4))
is not even legal syntax in ANSI Smalltalk...
More information about the Squeak-dev