CL Unification: Class VECTOR-TEMPLATE
 

Class VECTOR-TEMPLATE

Package:

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

Class Precedence List:

VECTOR-TEMPLATE, SEQUENCE-TEMPLATE, ARRAY-TEMPLATE, TYPE-TEMPLATE, TEMPLATE, STANDARD-OBJECT, T.

Known Subclasses:

STRING-TEMPLATE.

Slots:

None.

Description:

The VECTOR-TEMPLATE class denotes those object that are used to unify against a VECTOR.

Template Syntax:

  #T(vector . <destructuring template lambda list>)
  

  #T(<CL vector type specifier> . <destructuring template lambda list>)
  

The VECTOR-TEMPLATE syntax denotes a VECTOR object. A VECTOR-TEMPLATE must be unified against an VECTOR object. The elements of the array must be unified against the <destructuring template lambda list>

Examples:

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

  cl-prompt> (setq e (unify #(0 1 42 3 4 5)  #T(vector 0 1 "FOO" 3 4 5)))
  --> Error: UNIFICATION-FAILURE

  cl-prompt> (setq e (unify #("foo" "bar" 42)) #T(vector _ _ ?x))
  #<ENVIRONMENT xxx>

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

  cl-prompt> (setq e (unify #("foo" "bar" 42) #T(vector _ &rest ?x)))
  #<ENVIRONMENT xxx>

  cl-prompt> (find-variable-value '?x e)
  #("bar" 42)

  cl-prompt> (setq e (unify #("foo" "bar" 42) #T((vector fixnum) _ &rest ?x)))
  --> Error: UNIFICATION-FAILURE
  

Affected By:

None.

Exceptional Situations:

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

See Also:

UNIFY

Notes:

ARRAY Structural Properties

There is no way to "unify" against structural properties of vectors like fill pointers and displacements.

Current Implementation Note

Type checking for templates like #T((vector fixnum) 1 2 3) is not yet implemented.

 

News

News in chronological order, most recent on top.

  • 2004-10-30
    Completed description.