Herby Vojčík wrote:
Russell Leggett wrote:

    Thanks for throwing out alternative syntaxes. We should keep beating
    on this anvil, shorter function syntax is well worth it. But we need
    a non-GLR parsing procedure that rejects ambiguous grammars.


So here's my pitch - I've been thinking over a lot of the different
syntaxes that have been passed around, and I've got a combination that
might just work:

I know it's just bikeshedding, but do you need the -> arrow (it is better visually)? You can as well take arrowless approach but putting : before every parameter (as I suggested):

It's easy to get on thin ice without the arrow, due to destructuring parameters vs. array literal expression bodies, unary +/-, leading [ vs. [] as indexing operator, and of course /. Consider

  :x = default_x [x,x*x]

That [ indexes into the default_x that was intended as the parameter default value for x. Oops.

Saying "parenthesize!" does not help if the author then parenthesizes the body:

  :x = default_x ([x,x*x])

further on there could be an expression body, in which case the whole thing parses and the p.d.v. is default_x([x,x*x]).

Waldemar pointed out flaws of the general kind that affect paren-free "head" expression run together with an expression body:

https://mail.mozilla.org/pipermail/es-discuss/2011-September/016804.html

For paren-free statements, I plan to fix this by making newlines more significant (haven't had time to write it up). For what you've proposed, we cannot require a newline between parameter list and expression body.

So while you could come up with an unambiguous grammar, the readability is poor at the margin and maintainability goes down under obvious editing scenarios.

Again there is some future-unfriendliness but perhaps not worth much worry (but it still dogs proposals that shrug it off).

Arrows avoid all readability and future-proofing concerns that arise from running the (paren-free!) parameter list up against the expression body.

/be

_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to