CL Unification: Macros MATCH and MATCHF
 

Macro MATCH

Package:

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

Syntax:

  match (template object &key substitution errorp error-value) &body forms
  => results*
  

  matchf (template object &key substitution errorp error-value) &body forms
  => results*
  

Arguments and Values:

template---a unification template

object---an object

substitution---a substitution

errorp---a generalized boolean

error-value---an object

forms---an implicit progn

results---the values returned by forms

Description:

MATCH sets up a lexical environment to evaluate forms after a unification operation. MATCH unifies a template and an object and then sets up a lexical environment where the variables present in the template are bound lexically. Note that both variable names '?FOO' and 'FOO' are bound for convenience.

The MATCH form returns the values returned by the evaluation of the last of the forms.

If errorp is non-NIL (the default) then the form raises a UNIFICATION-FAILURE, otherwise the result of evaluating error-value, whose default is NIL is returned.

MATCHF works as MATCH but it does not evaluate template; it is useful whenever the template is cons that needs to be used as-is, without resorting to explicit quoting.

Affected By:

None.

Exceptional Situations:

See above.

See Also:

UNIFY, UNIFICATION-FAILURE

Notes:

Note that UNIFICATION-FAILUREs raising from the evaluation of forms will also be caught and handled by the enclosing MATCH according to errorp settings.