CL Unification: Class STRING-TEMPLATE
 

Class STRING-TEMPLATE

Package:

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

Class Precedence List:

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

Known Subclasses:

None.

Slots:

None.

Description:

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

Template Syntax:

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

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

The <destructuring template lambda list> has a slight different interpretation in this case, in order to provide more flexibility to the user. Ordinarily, each component appearing in a <destructuring template lambda list> is unified "element-wise" with the underlying SEQUENCE or ARRAY object. In the case of a STRING-TEMPLATE, each component of the <destructuring template lambda list> is allowed to be a STRING or a STRING-TEMPLATE itself. The STRING or STRING-TEMPLATE is unified against a subsequence of the CHARACTER VECTOR.

Examples:

  cl-prompt> (setf e (unify "foobar" #T(string "foob" ?x #\r)))
  #<ENVIRONMENT xxx>
  
  cl-prompt> (find-variable-value '?x e)
  #\a

  cl-prompt> (setq e (unify "foobar"  #T(string "FOO" #\b #\a #\r)))
  --> Error: UNIFICATION-FAILURE

  cl-prompt> (setq e (unify "foobar") #T(string _ _ ?x _ _ _))
  #<ENVIRONMENT xxx>

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

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

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

Affected By:

The value of the variable *UNIFY-STRING-CASE-SENSITIVE-P*.

Exceptional Situations:

Unifying an STRING-TEMPLATE against a non CHARACTER 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

The STRING-TEMPLATE class and the relevant UNIFY methods have not been implemented yet.

The actual semantics of the STRING-TEMPLATE class is not completely clear yet.

 

News

News in chronological order, most recent on top.

  • 2004-10-30
    Completed description.