CL Unification: Class SEQUENCE-TEMPLATE
 

Class SEQUENCE-TEMPLATE

Package:

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

Class Precedence List:

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

Known Subclasses:

VECTOR-TEMPLATE, LIST-TEMPLATE.

Slots:

None.

Description:

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

Template Syntax:

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

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

Examples:

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

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

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

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

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

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

  cl-prompt> (setq e (unify "I am a string" #T(sequence ?I _ &rest ?x)))
  #<ENVIRONMENT xxx>

  cl-prompt> (find-variable-value '?x e)
  "am a string"
  T

  cl-prompt> (find-variable-value '?I e)
  #\I
  T

  cl-prompt> (setq e (unify 42 #T(sequence _ &rest ?x)))
  --> Error: UNIFICATION-FAILURE

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

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

  cl-prompt> (find-variable-value '?foo e)
  33
  T
  

Affected By:

None.

Exceptional Situations:

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

See Also:

UNIFY

Notes:

None.

 

News

News in chronological order, most recent on top.

  • 2004-10-30
    Completed description.