CL Unification: Class STRUCTURE-OBJECT-TEMPLATE
 

Class STRUCTURE-OBJECT-TEMPLATE

Package:

COMMON-LISP.EXTENSIONS.DATA-AND-CONTROL-FLOW.UNIFICATION

Class Precedence List:

STRUCTURE-OBJECT-TEMPLATE, TYPE-TEMPLATE, TEMPLATE, STRUCTURE-OBJECT, T.

Known Subclasses:

None.

Slots:

None.

Description:

The STRUCTURE-OBJECT-TEMPLATE class denotes those object that are used to unify against any STRUCTURE-OBJECT.

Template Syntax:

  #T(<CL structure class designator> [<reader function> <object>]*)
  

The STRUCTURE-OBJECT-TEMPLATE syntax denotes any CL object that is an instance of a STRUCTURE-OBJECT. The syntax is such that the <reader function> gets called against the instance against which the STRUCTURE-OBJECT-TEMPLATE is being UNIFYed. <object> can be any CL object, including a TEMPLATE (in which case the unification machinery proceeds recursively.)

Examples:

  cl-prompt> (defstruct foo () (a 42))
  FOO

  cl-prompt> (defstruct (baz (:include foo)) (b 33))
  BAZ

  cl-prompt> (setf e (unify (make-foo) #T(foo foo-a 42)))
  #<ENVIRONMENT xxx>

  cl-prompt> (setf e (unify (make-baz) #T(foo foo-a 42)))
  #<ENVIRONMENT xxx>

  cl-prompt> (find-variable-value '?x e)
  42
  T

  cl-prompt> (setf e (unify (make-instance 'bar) #T(foo foo-a 42)))
  #<ENVIRONMENT xxx>

  cl-prompt> (find-variable-value '?x e)
  42
  T

  cl-prompt> (setf e (unify (make-instance 'baz) #T(baz the-a-in-baz 42)))
  #<ENVIRONMENT xxx>

  cl-prompt> (find-variable-value '?x e)
  42
  T

  cl-prompt> (setf e (unify (make-instance 'baz :b '?e) #T(baz bazb 42)))
  #<ENVIRONMENT xxx>

  cl-prompt> (find-variable-value '?x e)
  42
  T

  cl-prompt> (setf e (unify (make-instance 'bar) #T(baz foo-a 42)))
  --> Error: UNIFICATION-FAILURE
  

Affected By:

None.

Exceptional Situations:

Unifying a STRUCTURE-OBJECT-TEMPLATE against a non-STRUCTURE-OBJECT object results in an UNIFICATION-FAILURE error being signaled.

Unifying a STRUCTURE-OBJECT-TEMPLATE denoting an instance of structure S1 against an instance of structure S2, results in an UNIFICATION-FAILURE error being signaled, when S1 is not in the class precedence list of S2.

See Also:

UNIFY

Notes:

None.

 

News

News in chronological order, most recent on top.

  • 2004-10-30
    Completed description.