CL Unification: Class STANDARD-OBJECT-TEMPLATE
 

Class STANDARD-OBJECT-TEMPLATE

Package:

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

Class Precedence List:

STANDARD-OBJECT-TEMPLATE, TYPE-TEMPLATE, TEMPLATE, STANDARD-OBJECT, T.

Known Subclasses:

None.

Slots:

None.

Description:

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

Template Syntax:

  #T(<CL class designator> <slot spec>*)

  <slot spec> ::= <reader method> <object>
              |   (slot-value <slot name>) <object>
  

The STANDARD-OBJECT-TEMPLATE syntax denotes any CL object that is an instance of a STANDARD-OBJECT. The semantic of the template in a unification depends on which <slot spec>'s appear. In the first case the meaning of <slot spec> is such that the <reader method> gets called against the instance against which the STANDARD-OBJECT-TEMPLATE is being UNIFYed. In the second case, SLOT-VALUE is called with the instance being UNIFYed and <slot name>. The result value of the call to either <reader method>, or SLOT-VALUE is UNIFYed against <object>.

<object> can be any CL object, including a TEMPLATE (in which case the unification machinery proceeds recursively.)

Examples:

  cl-prompt> (defclass foo () ((a :initform 42 :accessor foo-a)))
  #<STANDARD-CLASS FOO XXXXX>

  cl-prompt> (defclass bar (foo) ())
  #<STANDARD-CLASS BAR XXXXX>

  cl-prompt> (defclass baz ()
               ((a :reader the-a-in-a-baz)
                (b :accessor bazb :initarg :b)))
  #<STANDARD-CLASS BAZ XXXXX>

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

  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 '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) #T(baz (slot-value b) 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 STANDARD-OBJECT-TEMPLATE against a non-STANDARD-OBJECT object results in an UNIFICATION-FAILURE error being signaled.

Unifying a STANDARD-OBJECT-TEMPLATE denoting an instance of class C1 against an instance of class C2, results in an UNIFICATION-FAILURE error being signaled, when C1 is not in the class precedence list of C2.

See Also:

UNIFY

Notes:

None.

 

News

News in chronological order, most recent on top.

  • 2004-10-30
    Completed description.