4.9 Keywords
Keywords in The Racket Guide introduces keywords.
A keyword is like an interned symbol, but its printed form starts with #:, and a keyword cannot be used as an identifier. Furthermore, a keyword by itself is not a valid expression, though a keyword can be quoted to form an expression that produces the symbol.
Two keywords are eq? if and only if they print the same (i.e., keywords are always interned).
Like symbols, keywords are only weakly held by the internal keyword table; see Symbols for more information.
See Reading Keywords for information on reading keywords and Printing Keywords for information on printing keywords.
procedure
(keyword->string keyword) → string?
keyword : keyword?
See also keyword->immutable-string from racket/keyword.
> (keyword->string '#:apple) "apple"
procedure
(string->keyword str) → keyword?
str : string?
> (string->keyword "apple") '#:apple
> (keyword<? '#:apple '#:banana) #t
Changed in version 7.0.0.13 of package base: Allow one argument, in addition to allowing two or more.
4.9.1 Additional Keyword Functions
(require racket/keyword) | package: base |
Added in version 7.6 of package base.
procedure
(keyword->immutable-string sym) → (and/c string? immutable?)
sym : keyword?
> (keyword->immutable-string '#:apple) "apple"
> (immutable? (keyword->immutable-string '#:apple)) #t
Added in version 7.6 of package base.