nil or #nil? (What the ANSI Standard says)

Allen Wirfs-Brock Allen_Wirfs-Brock at Instantiations.com
Tue Aug 25 18:46:51 UTC 1998


As a point of reference, here is what the ANSI standard for Smalltalk says
about literals. Note that the meaning of identifiers other than nil, true,
and false in literal arrays is explicitly specified as undefined. This is
an intentional loophole intended to allow a limit degree of backwards
compatability with ST-80 style array literals:

3.4.6 Literals
A literal is a syntactic construct that that directly describes a
statically created object. Instances of several classes of objects can be
represented literally. These include numbers, characters, strings, symbols,
message selectors, and arrays. Each type of literal is discussed in
individual sections below. For each type of literal, a protocol is
specified to which objects of that literal form must conform.

<literal> ::=
	<number literal> |
	<string literal> |
	<character literal> |
	<symbol literal> |
	<selector literal> |
	<array literal> 

The protocols specified for literals do not include any messages that
modify the state of the literal objects. The effect of sending a message to
an object that is the value of a literal that modifies the state of the
literal is undefined.

Multiple identical literals may occurs within a Smalltalk program. It is
unspecified whether the values of identical literals are the same or
distinct objects. It is also unspecified whether the values of separate
evaluations of a particular literal are the same or distinct objects. 

....

3.4.6.6 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

The value of an array literal is an object that implements the
<sequencedReadableCollection> protocol. The elements of an array literal
can consist of any combination of literal forms. If an identifier appears
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>. If an <array literal> has no
<array element>clauses the collection has no elements.





More information about the Squeak-dev mailing list