| string->symbol(3scm) | Scheme Programmer's Manual | string->symbol(3scm) |
NAME
string->symbol - string to symbol conversion
LIBRARY
(import (rnrs)) ;R6RS (import (rnrs base)) ;R6RS (import (scheme r5rs)) ;R7RS (import (scheme base)) ;R7RS
SYNOPSIS
(string->symbol string)
DESCRIPTION
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 ||).
RETURN VALUES
Returns a single value; a symbol.
EXAMPLES
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
COMPATIBILITY
This procedure is in all Scheme reports starting with R2RS.
ERRORS
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.
SEE ALSO
symbol->string(3scm)
STANDARDS
R4RS, IEEE Scheme, R5RS, R6RS, R7RS
HISTORY
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.
AUTHORS
This page is part of the scheme-manpages project. It includes materials from the RnRS documents. More information can be found at https://weinholt.se/scheme/manpages/.
BUGS
There are implementations that do not garbage collect the symbol interning table.
| 2022-05-13 |