Has a generalization of the conventional meaning -- evaluate the right
hand expression and match it against the pattern on the left. We refer
to the value of the right hand expression as the specimen. Should
the match fail, the define expression throws a to-be-specified problem
explaining the match failure.

BNF:

"def" pattern ":=" eExpr

XML DTD:

<!ELEMENT defineExpr (%pattern;, %eExpr;)>

Java:

When the pattern might fail, it is expanded to throw an exception
rather than produce a boolean.

The throw must be happen as soon as match failure is detected, without
any further pattern matching activity. Therefore, the define expression
can avoid the double-definition issue which plagues the match-bind
expression. Succeeding scopes only see successful bound variables. If
the match succeeds, the value of the define expression is the specimen.

Technically, the right hand expression is also in scope of the left hand
pattern. However, this raises the possibility of circular definitions.
While the User-E language does allow such circular definitions, Kernel-E
does not. In the Kernel-E define expression, the expression may not use
any varibles by the pattern, and the patterns may not use any variable
defined by the expression. Though this second restriction may now seem
well motivated, the two together allows code which processes Kernel-E
trees to treat the parts of a define expression as if they occur in the
reverse order, ie, in their execution order.

Unless stated otherwise, all text on this page which is either unattributed
or by Mark S. Miller is hereby placed in the public domain.