DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

(guile.info.gz) Symbol Props

Info Catalog (guile.info.gz) Symbol Primitives (guile.info.gz) Symbols (guile.info.gz) Symbol Read Syntax
 
 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.
 
  -- 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.  (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.
 
Info Catalog (guile.info.gz) Symbol Primitives (guile.info.gz) Symbols (guile.info.gz) Symbol Read Syntax
automatically generated byinfo2html