[previous] [up] [next]     [index]
Next: Parameters Up: Global Variable Namespaces Previous: Global Names

Keywords

Keyword names cannot be redefined or used as local variable names. All built-in keyword names are prefixed with #%, and a keyword binding is created for all primitive syntactic forms and procedures: for every built-in procedure or syntactic form x, there is a corresponding keyword #%x that accesses the same syntax or value.

There are no other built-in global keywords. Local keywords--such as public within a class* expression--are not globally enforced. This means, for example, that the name public may be bound to a value, but public as the first part of a class* sub-clause will not notice such a binding.

A new keyword is declared with (keyword-name symbol). Once a symbol has been designated as a keyword, it cannot be bound locally or globally. (If symbol was not already defined, it will be defined as void.) Keywords declared this way are local to the namespace. Test for keywords in the current namespace with (keyword-name? symbol).

Once a name is declared as a keyword, it is syntactically disallowed in any binding position. However, it is possible that a previously-compiled define or set! expression tries to change the value of keyword global binding, or global-defined-value may be used on a keyword binding. In that case, exn:variable:keyword exception is raised is raised at run-time.

A namespace can be created where the built-in #%-prefixed names are not keywords (see section 9.3), but some built-in syntax and procedures will fail in this namespace if certain #%-prefixed names are re-defined or shadowed.



PLT