Kaz Kylheku
10/5/2015 2:57:00 PM
On 2015-10-05, CAI GENGYANG <gengyangcai@gmail.com> wrote:
> Ok, so basically nil and 'nil are the same thing ...
Two different syntactic forms which evaluate to the same thing
*are* the same thing only in languages in which syntax itself
isn't an object.
One such language is conventional mathematics. We have some justification
in asserting that 2x "is the same thing as" x + x.
In Lisp, 'nil and nil evaluate to the same value, but they aren't
the same syntax. That matters in situations in which they are not
evaluated.
One such obvious situation occurs when we pile on just one more quote:
Whereas these evaluate to the same thing
nil -> nil
'nil -> nil
If we quote them, they do not:
'nil -> nil
''nil -> (nil)
In Lisp there are many situations in which nil is specified as an argument,
and isn't evaluated. For instance:
(lambda () ...) ;; function with no arguments
Here, we cannot replace () with '():
(lambda '() ...) ;; function with one invalid argument
This second lambda is actually the syntax (lambda (nil) ...).
On the other hand we are *usually* justified in asserting that nil and NIL
are the same, and nil and () are the same thing.
Of course if these forms are stored in character strings, they are not
the same character strings. However, under usual circumstances, they
denote the same syntax when scanned as input by Lisp.
This isn't always so. The reader can be configured so that nil and NIL
are different symbols. Moreover, in your own package, you can have a
symbol nil which isn't common-lisp:nil, and that symbol doesn't
evaluate to itself, and isn't equivalent to the () notation.