Next: , Previous: , Up: Symbols   [Contents][Index]


6.6.6.5 Function Slots and Property Lists

In traditional Lisp dialects, symbols are often understood as having three kinds of value at once:

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, one for a symbol’s property list, and one for its “function value.” The following procedures are provided to access these slots.

Scheme Procedure: symbol-fref symbol
C Function: scm_symbol_fref (symbol)

Return the contents of symbol’s function slot.

Scheme Procedure: symbol-fset! symbol value
C Function: scm_symbol_fset_x (symbol, value)

Set the contents of symbol’s function slot to value.

Scheme Procedure: symbol-pref symbol
C Function: scm_symbol_pref (symbol)

Return the property list currently associated with symbol.

Scheme Procedure: symbol-pset! symbol value
C Function: scm_symbol_pset_x (symbol, value)

Set symbol’s property list to value.

Scheme Procedure: symbol-property sym prop

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.

Scheme Procedure: set-symbol-property! sym prop val

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.

Scheme Procedure: symbol-property-remove! sym prop

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. For a more modern and Schemely approach to properties, see Object Properties.


Next: , Previous: , Up: Symbols   [Contents][Index]