Node:Symbol Props,
Next:Symbol Read Syntax,
Previous:Symbol Primitives,
Up:Symbols
21.6.5 Function Slots and Property Lists
In traditional Lisp dialects, symbols are often understood as having
three kinds of value at once:
- a variable value, which is used when the symbol appears in
code in a variable reference context
- a function value, which is used when the symbol appears in
code in a function name position (i.e. as the first element in an
unquoted list)
- a property list value, which is used when the symbol is given as
the first argument to Lisp's
put
or get
functions.
Although Scheme (as one of its simplifications with respect to Lisp)
does away with the distinction between variable and function namespaces,
Guile currently retains some elements of the traditional structure in
case they turn out to be useful when implementing translators for other
languages, in particular Emacs Lisp.
Specifically, Guile symbols have two extra slots. for a symbol's
property list, and for its "function value." The following procedures
are provided to access these slots.
symbol-fref symbol
|
Scheme Procedure |
scm_symbol_fref (symbol)
|
C Function |
Return the contents of symbol's function slot.
|
symbol-fset! symbol value
|
Scheme Procedure |
scm_symbol_fset_x (symbol, value)
|
C Function |
Set the contents of symbol's function slot to value.
|
symbol-pref symbol
|
Scheme Procedure |
scm_symbol_pref (symbol)
|
C Function |
Return the property list currently associated with symbol.
|
symbol-pset! symbol value
|
Scheme Procedure |
scm_symbol_pset_x (symbol, value)
|
C Function |
Set symbol's property list to value.
|
symbol-property sym prop
|
Scheme Procedure |
From sym's property list, return the value for property
prop. The assumption is that sym's property list is an
association list whose keys are distinguished from each other using
equal? ; prop should be one of the keys in that list. If
the property list has no entry for prop, symbol-property
returns #f .
|
set-symbol-property! sym prop val
|
Scheme Procedure |
In sym's property list, set the value for property prop to
val, or add a new entry for prop, with value val, if
none already exists. For the structure of the property list, see
symbol-property .
|
symbol-property-remove! sym prop
|
Scheme Procedure |
From sym's property list, remove the entry for property
prop, if there is one. For the structure of the property list,
see symbol-property .
|
Support for these extra slots may be removed in a future release, and it
is probably better to avoid using them. (In release 1.6, Guile itself
uses the property list slot sparingly, and the function slot not at
all.) For a more modern and Schemely approach to properties, see
Object Properties.