Mooncrater
Mooncrater

Reputation: 4881

Symbols Produced By Intern

Here is a code snippet:

CL-USER> (setf (symbol-value (intern "foo")) 98)
98
CL-USER> foo
; Evaluation aborted on #<UNBOUND-VARIABLE FOO {1003FC6213}>.
CL-USER> |foo|
98

The symbol created by intern has a "|" in front and end of the symbol I created. But in this answer, foo is set as the name of the symbol, not |foo|. So, why is this happening?

Upvotes: 1

Views: 298

Answers (2)

Rainer Joswig
Rainer Joswig

Reputation: 139411

Note that the || is not a part of the symbol. It's just a character pair for escaping the enclosed symbol. This ensures that the exact case of the characters is used when reading the symbol.

Upvotes: 3

Daniel Keogh
Daniel Keogh

Reputation: 233

(intern "foo") is appearing as |foo| because intern is case sensitive.

See that in the answer you linked to that (intern "FOO") is capitalized.

Upvotes: 4

Related Questions