Allowing multiple let clauses in LetExpr and for clauses in ForExpr

Currently, it is possible to have multiple SimpleLetBindings in a
SimpleLetClause, but not have multiple SimpleLetClauses in a LetExpr. The
same applies for ForExpr.

I propose that this should be possible. In other words, make the following
changes to the XPath 4.0 grammar:

[12] ForExpr ::= SimpleForClause SimpleForClause* "return" ExprSingle
[15] LetExpr ::= SimpleLetClause SimpleLetClause* "return" ExprSingle

This way, a user can write the following in XPath 4.0:

    let $x := 1.0
    let $y := 2.0
    return $x + $y

in addition to the following in XPath 3.1 and earlier:

    let $x := 1.0, $y := 2.0
    return $x + $y

Note that this does not add any new capability to XPath (in particular, for
and let clauses cannot be mixed like in XQuery) as a user can define
multiple let or for clauses, it just provides them with an alternative way
of expressing that like they can do in XQuery (where it is common to use a
series of let clauses instead of let bindings for multiple local variables).

Kind regards,
Reece

Received on Sunday, 13 December 2020 15:03:27 UTC