ERights Home elang / kernel 
Back to: Assignment Expression x On to: Match-Bind Expression

Sequence Expression


Has the conventional meaning -- evaluates the expressions in order. The value of the sequence expression as a whole is the value of the last expression. If any of the ealier expressions perform a non-local exit, then all later expressions are skipped and the sequence expression as a whole performs the same non-local exit.

BNF:
eExpr ("\n", eExpr)*
XML DTD:
<!ELEMENT seqExpr ((%eExpr;)+)>
Java:
In a non-value context (a for-effect-only context), it's just the same sequence of expressions. In a value context, we assign the value of the last expression to our result variable.
Example:
def x := {
    println("foo")
    bar()
}
in Kernel-E:
def x :any := {
    println.run("foo")
    bar.run()
}
in XML:
<defineExpr>
    <finalPattern>
        <Noun>x</Noun>
        <Noun>any</Noun>
    </finalPattern>
    <hideExpr>
        <seqExpr>
            <callExpr>
                <Noun>println</Noun>
                <Verb>run</Verb>
                <String>foo</String>
            </callExpr>
            <callExpr>
                <Noun>bar</Noun>
                <Verb>run</Verb>
            </callExpr>
        </seqExpr>
    </hideExpr>
</defineExpr>
in Java:
Object result_3;
{
    E.call(println, "run" "foo")
    result_3 = E.call(bar, "run")
}
Object x = result_3;

With some work, we should be able to assign to "x" directly, and avoid creating the temporary "result_3".

 

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: Assignment Expression x On to: Match-Bind Expression
Download    FAQ    API    Mail Archive    Donate

report bug (including invalid html)

Golden Key Campaign Blue Ribbon Campaign