CL Unification: Class AREF-TEMPLATE
 

Class AREF-TEMPLATE

Package:

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

Class Precedence List:

AREF-TEMPLATE, ELEMENT-TEMPLATE, EXPRESSION-TEMPLATE, TEMPLATE, STANDARD-OBJECT, T.

Known Subclasses:

None.

Slots:

None.

Description:

The AREF-TEMPLATE class denotes those object that are used to unify against a particular element of an ARRAY.

Template Syntax:

  #T(aref (index1 ... indexN) item)
  

  #T(aref index item)
  

The AREF-TEMPLATE syntax denotes the item at index1 ... indexN of an ARRAY. An AREF-TEMPLATE must be unified against a ARRAY object. item is unified against the element extracted from the sequence object at index1 ... indexN by the standard function AREF.

The second form is a shorthand.

  #T(aref index item) <==> #T(aref (index) item)
  

Examples:

  cl-prompt> (setf e (unify #(0 1 42 3 4 5) #T(aref 2 ?x)))
  #<ENVIRONMENT xxx>
  
  cl-prompt> (find-variable-value '?x e)
  42

  cl-prompt> (setq e (unify #(0 1 42 3 4 5) #T(aref 42 ?x)))
  --> Error: index 42 out of bounds.


  cl-prompt> (setq e (unify 42 #T(aref 42 ?x)))
  --> Error: UNIFICATION-FAILURE


  cl-prompt> (setq e (unify "This is a string!" #T(aref 4 ?x)))
  #<ENVIRONMENT xxx>

  cl-prompt> (find-variable-value '?x e)
  #\Space  


  cl-prompt> (setq e (unify #2A((1 0) (foo bar)) #T(aref (1 1) ?x)))
  #<ENVIRONMENT xxx>

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


  cl-prompt> (setq e (unify #2A((1 0) (foo bar)) #T(aref (1 1) baz)))
  --> Error: UNIFICATION-FAILURE


  cl-prompt> (setq e (unify #2A((1 0) (foo ?x)) #T(aref (1 1) baz)))
  #<ENVIRONMENT xxx>

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

Affected By:

None.

Exceptional Situations:

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

See Also:

UNIFY

Notes:

None.