ERights Home elang / kernel 
Back to: Plumbing Expression On to: VarPattern

FinalPattern


The Identifier is the defining occurence of a variable name, and the eExpr is the ValueGuard-expression. When matched against a specimen, a FinalPattern defines the variable to have as its value the specimen as coerced by the ValueGuard. A variable declared by a FinalPattern may not be assigned to, and programs that contain such an assignment must be statically rejected. XXX The current E implementations only rejects such assignments dynamically, not statically.

BNF:
Noun ":" eExpr
XML DTD:
<!ELEMENT finalPattern (Noun, %eExpr;)>
Java:

A variable defined by a FinalPattern is always simple. The guard ":any" has a statically known meaning, since "any" is an unshadowable name bound in the universal scope. Given that "T" below is statically determined to be a particular Java class, and using "foo" for all other ValueGuard expressions, we have the following cases:

x :any
final Object x = specimen;
x :T
final T x = E.as(specimen,
                 T.class,
                 optEjector);
x :foo
final Object x = E.call(foo,
                        "coerce",
                        specimen,
                        optEjector);
Example:
def a :foo := b
in Kernel-E:
same
in XML:
<defineExpr>
    <finalPattern>
        <Noun>a</Noun>
        <Noun>foo</Noun>
    </finalPattern>
    <Noun>b</Noun>
</defineExpr>
in Java:
final Object a = E.call(foo, "coerce", b, null);

 

x
 
Unless stated otherwise, all text on this page which is either unattributed or by Mark S. Miller is hereby placed in the public domain.
ERights Home elang / kernel 
Back to: Plumbing Expression On to: VarPattern
Download    FAQ    API    Mail Archive    Donate

report bug (including invalid html)

Golden Key Campaign Blue Ribbon Campaign