DefineExpr
From Erights
(Difference between revisions)
(→Examples) |
Kevin Reid (Talk | contribs) (specify DefineExpr) |
||
Line 1: | Line 1: | ||
[[DefineExpr]] is a [[Kernel-E]] node which matches a [[pattern]] against a specified value. | [[DefineExpr]] is a [[Kernel-E]] node which matches a [[pattern]] against a specified value. | ||
- | "def" <var>pattern</var> ("exit" <var> | + | "def" <var>pattern</var> ("exit" <var>optEjectorExpr</var>)? ":=" <var>rValue</var> |
Note that the syntax is identical to [[DefrecExpr]], the nonkernel expression which allows ''recursive'' definitions; DefineExpr rejects such uses. | Note that the syntax is identical to [[DefrecExpr]], the nonkernel expression which allows ''recursive'' definitions; DefineExpr rejects such uses. | ||
Line 8: | Line 8: | ||
* <var>pattern</var> :[[Pattern]] | * <var>pattern</var> :[[Pattern]] | ||
- | * <var> | + | * <var>optEjectorExpr</var> :[[nullOk]]<nowiki>[</nowiki>[[EExpr]]] |
- | * <var> | + | * <var>rValue</var> :[[EExpr]] |
== Scope == | == Scope == | ||
- | [[Node scope rules|seq]](<var>pattern</var>, <var> | + | [[Node scope rules|seq]](<var>pattern</var>, <var>optEjectorExpr</var>, <var>rValue</var>) |
- | + | ||
- | + | ||
== Evaluation == | == Evaluation == | ||
- | # If present, <var> | + | # If present, <var>optEjectorExpr</var> is evaluated. |
- | # <var> | + | # <var>rValue</var> is evaluated. |
- | #<var>pattern</var> is matched against the result of <var> | + | #<var>pattern</var> is matched against the result of <var>rValue</var>, with the result of <var>optEjectorExpr</var>, or [[throw]] if not present, as the ejector. |
== Static constraints == | == Static constraints == | ||
- | * <var> | + | * <var>rValue</var> may not use nouns bound by <var>pattern</var>. (See [[DefrecExpr]].) |
- | * <var> | + | * <var>optEjectorExpr</var> may not use nouns bound by <var>pattern</var>. |
- | * <var>pattern</var> may not use nouns bound by <var> | + | * <var>pattern</var> may not use nouns bound by <var>rValue</var>. |
- | * <var>pattern</var> may not use nouns bound by <var> | + | * <var>pattern</var> may not use nouns bound by <var>optEjectorExpr</var>. |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
[[Category:E language specification]] | [[Category:E language specification]] | ||
[[Category:Kernel-E nodes]] | [[Category:Kernel-E nodes]] |
Revision as of 05:03, 4 January 2009
DefineExpr is a Kernel-E node which matches a pattern against a specified value.
"def" pattern ("exit" optEjectorExpr)? ":=" rValue
Note that the syntax is identical to DefrecExpr, the nonkernel expression which allows recursive definitions; DefineExpr rejects such uses.
Contents |
Fields
Scope
seq(pattern, optEjectorExpr, rValue)
Evaluation
- If present, optEjectorExpr is evaluated.
- rValue is evaluated.
- pattern is matched against the result of rValue, with the result of optEjectorExpr, or throw if not present, as the ejector.
Static constraints
- rValue may not use nouns bound by pattern. (See DefrecExpr.)
- optEjectorExpr may not use nouns bound by pattern.
- pattern may not use nouns bound by rValue.
- pattern may not use nouns bound by optEjectorExpr.