On Mar 7, 6:17 pm, “Rick DeNatale” [email protected] wrote:
one of the slots in a symbol.
Actually it’s five in Common Lisp: Value, Function, Name, Property
List, Package.
Note that inLispthe value of a Symbol is separate from it’s name,
and two Symbols can have the same value, they just can’t have the same
name.
No, that’s wrong. Two different symbols can have the same name in
Common Lisp.
CL-USER 30 > (eq '#:foo '#:foo)
NIL
CL-USER 31 > (symbolp '#:foo)
T
CL-USER 32 > (symbol-name '#:foo)
“FOO”
So inLispa symbol is more like an entry in the table of global names.
No. In Lisp a symbol is a data structure with above five (virtual)
slots.
Symbols can exist without a ‘table of names’. These ‘table of names’
are called packages. A symbol can belong to a package. You can then
lookup the symbol via the package by its name. Again a symbol
can exist without being interned in a package.
Symbols in Ruby and Smalltalk are more alike than Symbols inLisp.
Smalltalk and Ruby symbols have unique ‘values’ which are also their ‘names’.
These are a bit keyword symbols in Lisp. All symbols that belong to
the keyword package
have themselves as the value.
CL-USER 30 > (eq '#:foo '#:foo)
NIL
CL-USER 31 > (symbolp '#:foo)
T
CL-USER 32 > (symbol-name '#:foo)
“FOO”
CL-USER 33 > :foo
:FOO
CL-USER 34 > (symbol-package :foo)
#<The KEYWORD package, 0/4 internal, 9284/32768 external>
CL-USER 35 > (eq :foo (symbol-value :foo))
T
CL-USER 36 > (describe ':foo)
:FOO is a SYMBOL
NAME “FOO”
VALUE :FOO
FUNCTION #
PLIST NIL
PACKAGE #<The KEYWORD package, 0/4 internal, 9284/32768
external>