Class LIST-TEMPLATE
Package:
COMMON-LISP.EXTENSIONS.DATA-AND-CONTROL-FLOW.UNIFICATION
Class Precedence List:
LIST-TEMPLATE, SEQUENCE-TEMPLATE, TYPE-TEMPLATE, TEMPLATE, STANDARD-OBJECT, T.
Known Subclasses:
None.
Slots:
None.
Description:
The LIST-TEMPLATE class denotes those object that are used to unify against a LIST.
Template Syntax:
#T(list . <destructuring template lambda list>)
The LIST-TEMPLATE syntax denotes a LIST object. A LIST-TEMPLATE must be unified against a LIST object. The elements of the list must be unified against the <destructuring template lambda list>
Examples:
cl-prompt> (setf e (unify '(0 1 42 3 4 5) #T(list 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(list 0 1 "FOO" 3 4 5))) --> Error: UNIFICATION-FAILURE cl-prompt> (setq e (unify '("foo" "bar" 42)) #T(list _ _ ?x)) #<ENVIRONMENT xxx> cl-prompt> (find-variable-value '?x e) 42 T cl-prompt> (setq e (unify #(1 2 3) #T(list _ &rest ?x))) --> Error: UNIFICATION-FAILURE cl-prompt> (setq e (unify (list "foo" '?foo 42)) #T(list _ 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 a LIST-TEMPLATE against a non-LIST object results in an UNIFICATION-FAILURE error being signaled.
See Also:
UNIFY
Notes:
Unifying a LIST-TEMPLATE against a non-proper or circular list has undefined behavior.
The LIST-TEMPLATE class is the only one that is really needed in order not to implode the overall unification machinery. But, since it is needed, then it is worthwhile to build the whole template hierarchy.