Open julianhyde opened 1 year ago
I just merged #216, which allows you to use commas in join
. While
from x in list1 where x.a > 10,
y in list2,
z in list3
yield {x, y, z}
remains illegal, you can now write
from x in list1
where x.a > 10
join y in list2,
z in list3
yield {x, y, z}
which looks pretty good to me.
Currently the
from
expression starts with several "scan" expressions of the form "id in list" or "id = list", separated by commas, and then a sequence of clauses including "join", "where", "group", "yield". "join" means pretty much the same as ",".The following is currently illegal:
With this feature it would be legal. It is convenient to be able to add a
where
after a scan (x in list1
) and to still be able to follow it with a comma and another scan (, y in list2
).The following is equivalent and is already legal:
As is the following:
But we cannot just enable the comma. The
group
andorder
clauses allow commas, and comma as the start of a clause would be ambiguous, as the following illustrate. Group:Group compute:
Order:
To disambiguate, one option is to add parentheses to
group
andorder
syntax when there is more than one key/expression. Here are some examples with the new syntax:group x.a
group (x.a, x.b)
group x.a compute (sum(x.c), sum(x.d))
order x.a desc
order (x.a desc, x.b)
Note that composite
yield
already requires parentheses.