Symbols are objects whose usefulness rests on the fact that two
symbols are identical (in the sense of equal?) if and only if their
names are spelled the same way.
This is exactly the property needed to
represent identifiers, so most
implementations of Lisp dialects use them internally for that purpose. Symbols
are useful for many other applications; for instance, they may be used
the way enumerated values are used in Pascal.
Typically, two symbols may be compared for equality in constant time,
no matter how long their names.
[74] symbol = identifier
The rules for writing a symbol are exactly the same as the rules for
writing an identifier.
8.5.4.1 Symbol Type Predicate
(symbol? obj)
Returns #t if obj is a symbol, and otherwise returns
#f.
(symbol? 'foo) #t
(symbol? (car '(a b))) #t
(symbol? "bar") #f
(symbol? 'nil) #t
(symbol? '()) #f
(symbol? #f) #f
8.5.4.2 Symbol to String Conversion
(symbol->string symbol)
Returns the name of symbol as a string.
(symbol->string 'flying-fish) "flying-fish"
(symbol->string
(string->symbol "Malvina")) "Malvina"
8.5.4.3 String to Symbol Conversion
(string->symbol string)
Returns the symbol whose name is string. This procedure may
create symbols with names containing special characters,
but it is usually a bad idea to create such
symbols because they have no external representation.
See symbol->string.
(equal? 'mISSISSIppi 'mississippi) #f
(equal? 'bitBlt (string->symbol "bitBlt")) #t
(equal? 'JollyWog
(string->symbol
(symbol->string 'JollyWog))) #t
(string=? "K. Harper, M.D."
(symbol->string
(string->symbol "K. Harper, M.D.")) #t