|
|
|
|
|
by lispm
2165 days ago
|
|
For Lisp the following is the usual behavior: Symbols are by default interned and identical symbols are tested with EQ to be T. > (eq (read) (read))
a a
T
The default test function is EQL, which is using EQ to test symbols. In Common Lisp #:a would be an uninterned symbol with the name "A". > (find 'a '(#:a a))
A
> (find 'a '(#:a a) :test #'string-equal)
#:A
setting the value of a symbol will basically work in all Lisps with symbols in similar fashion like this: > (dolist (item '(a b c a))
(set item (if (and (boundp item)
(numberp (eval item)))
(1+ (eval item))
1)))
NIL
> (mapcar 'eval '(a b c a))
(2 1 1 2)
This last example will for example run unchanged in Emacs Lisp and Common Lisp. |
|