Keywords are similar to symbols. They are used mainly for specifying keyword arguments.
Historically keywords have been self-evaluating (you did not need to quote them). This has changed: you must quote a keyword if you want a literal keyword value, and not quote it if it is used as a keyword argument.
keyword
::=
identifier
:
| #:
identifier
The two syntaxes have the same meaning: The former is nicer-looking;
the latter is more portable (and required if you use the
--r7rs
command-line flag).
Details: In r7rs and other Scheme standards the colon character does not have any special meaning, so
foo:
orfoo:bar
are just regular identifiers. Therefore some other Scheme variants that have keywords (including Guile and Racket) use the#:
syntax. Kawa has some hacks so that most standard Scheme programs that have colons in identifiers will work. However, for best compatibility, use the--r7rs
command-line flag (which turns colon into a regular character in a symbol), and the#:
syntax.
A keyword is a single token; therefore no whitespace is allowed between
the identifier
and the colon or after the #:
;
these characters are not considered part of the name of the keyword.
Return
#t
ifobj
is a keyword, and otherwise returns#f
.
Procedure: keyword->string
keyword
Returns the name of
keyword
as a string. The name does not include the final#\:
.
Procedure: string->keyword
string
Returns the keyword whose name is
string
. (Thestring
does not include a final#\:
.)