Next: , Previous: , Up: baselib   [Index]


4.9 Symbols

Symbols are objects whose usefulness rests on the fact that two symbols are identical (in the sense of eq?, eqv? and equal?) if and only if their names are spelled the same way. A symbol literal is formed using quote.

Procedure: symbol? obj

Return #t if obj is a symbol, #f otherwise.

(symbol? 'foo)          ⇒ #t
(symbol? (car '(a b)))  ⇒ #t
(symbol? "bar")         ⇒ #f
(symbol? 'nil)          ⇒ #t
(symbol? '())           ⇒ #f
(symbol? #f)            ⇒ #f
Procedure: symbol->string symbol

Return the name of symbol as an immutable string.

(symbol->string 'flying-fish)                   ⇒  "flying-fish"
(symbol->string 'Martin)                        ⇒  "Martin"
(symbol->string (string->symbol "Malvina"))     ⇒  "Malvina"
Procedure: symbol=? symbol1 symbol2 symbol3

Return #t if the symbols are the same, i.e., if their names are spelled the same.

Procedure: string->symbol string

Return the symbol whose name is string.

(eq? 'mISSISSIppi 'mississippi)
⇒ #f

(string->symbol "mISSISSIppi")
⇒ the symbol with name "mISSISSIppi"

(eq? 'bitBlt (string->symbol "bitBlt"))
⇒ #t

(eq? 'JollyWog (string->symbol (symbol->string 'JollyWog)))
⇒ #t

(string=? "K. Harper, M.D."
          (symbol->string (string->symbol "K. Harper, M.D.")))
⇒ #t