Symbols

Symbols are objects whose usefulness rests on the fact that two symbols are identical (in the sense of eqv?) if and only if their names are spelled the same way. For instance, they can be used the way enumerated values are used in other languages.

The rules for writing a symbol are exactly the same as the rules for writing an identifier; see sections 2.1 and 7.1.1. It is guaranteed that any symbol that has been returned as part of a literal expression, or read using the read procedure, and subsequently written out using the write procedure, will read back in as the identical symbol (in the sense of eqv?).

(symbol? obj ) procedure
Returns #t if obj is a symbol, otherwise returns #f.
(symbol? 'foo) ==> #t (symbol? (car '(a b))) ==> #t (symbol? "bar") ==> #f (symbol? 'nil) ==> #t (symbol? '()) ==> #f (symbol? #f) ==> #f

(symbol=? symbol1 symbol2 symbol3 ... ) procedure
Returns #t if all the arguments are symbols and all have the same names in the sense of string=?.

(symbol->string symbol ) procedure
Returns the name of symbol as a string, but without adding escapes.
(symbol->string 'flying-fish) ==> "flying-fish" (symbol->string 'Martin) ==> "Martin" (symbol->string (string->symbol "Malvina")) ==> "Malvina"

(string->symbol string ) procedure
Returns the symbol whose name is string. This procedure can create symbols with names containing special characters that would require escaping when written, but does not interpret escapes in its input.
(string->symbol "mISSISSIppi") ==> mISSISSIppi (eqv? 'bitBlt (string->symbol "bitBlt")) ==> #t (eqv? 'LollyPop (string->symbol (symbol->string 'LollyPop))) ==> #t (string=? "K. Harper, M.D." (symbol->string (string->symbol "K. Harper, M.D."))) ==> #t

husk-scheme online documentation rev 3.2 (2021.03.04)