string->symbol - string to symbol conversion
(import (rnrs)) ;R6RS
(import (rnrs base)) ;R6RS
(import (scheme r5rs)) ;R7RS
(import (scheme base)) ;R7RS
Returns the symbol whose name is string.
This procedure can create symbols that cannot be read back with
read(3scm) after being written with write(3scm). In R6RS
implementations this happens when string is the empty string, because
there is no lexical syntax for the symbol with the empty name. (In R7RS the
empty symbol is written as ||).
Returns a single value; a symbol.
In the examples below the behavior would change if a case-folding reader was
used. This may be enabled with the #!fold-case
directive. In R6RS this directive appears in the non-normative appendix. In
R5RS and earlier reports it was possible for case conversion, either to upper
or lower case, to be enabled by default.
(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
This procedure is in all Scheme reports starting with R2RS.
This procedure can raise exceptions with the following condition types:
- &assertion (R6RS)
- The wrong number of arguments was passed or an argument was outside its
domain.
- R7RS
- The assertions described above are errors. Implementations may signal an
error, extend the procedure's domain of definition to include such
arguments, or fail catastrophically.
R4RS, IEEE Scheme, R5RS, R6RS, R7RS
This procedure first appeared with this name in R2RS. Earlier Scheme running on
MacLisp had the getpname procedure that returned an atomic symbol's
print name as a character string.
There are implementations that do not garbage collect the symbol interning
table.