[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.6 Keywords

Builtin Class: <keyword>
A keyword is a sort of a special symbol that is automatically quoted. It is extensively used in pass-by-name arguments (keyword arguments), and keyword-value list Unlike CommonLisp, keywords and symbols are distinct types.

See also let-keywords* macro ( Optional argument parsing) for keyword argument processing.

Reader syntax: :name
Read to a keyword whose name is name. (Note that the preceding ':' is not a part of the keyword's name.)

Function: keyword? obj
Returns #t iff obj is a keyword.

Function: make-keyword name
Returns a keyword whose name is name.

Function: keyword->string keyword
Returns the name of the keyword keyword.

Function: get-keyword key list &optional fallback
A useful procedure to extract a value from key-value list. A key-value list list must contains even number of elements; the first, third, fifth ... elements are regarded as keys, and the second, fourth, sixth ... elements are the values of the preceding keys.

This procedure looks for key from the keys, and if it finds one, it returns the corresponding value. If there are more than one matching keys, the leftmost one is taken. If there is no matching key, it returns fallback if provided, or signals an error otherwise.

It is an error if list is not a proper, even-number element list.

Actually, `keywords' in the keyword-value list and the key argument need not be a keyword--it can be any Scheme object. Key comparison is done by eq?.

This procedure is taken from STk.

Macro: get-keyword* key list &optional fallback
Like get-keyword, but fallback is evaluated only if list does not have key.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by Ken Dickey on November, 28 2002 using texi2html