nil or #nil?
Dwight Hughes
dwighth at ipa.net
Tue Aug 25 19:07:41 UTC 1998
David N. Smith wrote:
---snip---
>
> I agree that self is not a literal, but I'm not so sure about nil, true,
> and false.
>
> It can be argued that they are the only literal representation of three
> critical and commonly used values in Smalltalk. They might look like
> variables but they really aren't.
>
> So, what is a literal anyway?
I like Tom Burns' definition of a literal best (in a message to c.l.s.):
"Probably a correct definition of a Smalltalk literal is more like: an
expression from which the Compiler can immediately generate an object.
This would be opposed to a sequence of byte codes that must be evaluated
to create the object. For example, $A vs. 65 asCharacter."
In this light, nil, true, and false are literals - but so are #nil,
#true, and #false -- the problem right now is that nil ~~ #nil, true ~~
#true, and false ~~ #false, which is a bit counterintuitive. Would it
outrage anyone to consider nil, true and false to be syntactic sugar for
#nil, #true, and #false?
-- Dwight
More information about the Squeak-dev
mailing list
|