On 12-09-10 2:27 PM, Patrick Walton wrote:
Hi,
This leads to this issue:
let (let x, let y) = (1, 2);
And it would be very difficult to parse something like this:
(let x, let y) = (1, 2);
Because the parser would have to do unbounded lookahead here to
determine whether we're in a pattern or not.
Yeah. I have read through this thread and while I'm sympathetic to the
desire (you may recall I used to feel that ?x on variable-captures was
ideal) I'm not too warm to the actual details here.
Most syntax changes are a mixture of goods and bads and while I'm the
first to admit the residual sore spots in ours (I hit the
pattern-match-against-a-constant today, grr) I don't think the 'let to
bind each var' thing is going to help more than it hurts. Winds up
needing to add more special cases for the top-level-destructuring-let
and not-required-lets-when-nested cases, and makes things chattier.
This particular horse keeps coming up for a further kicking, so it may
not be _entirely_ dead yet. If I can concentrate the matter a bit in
order to clarify what you're dealing with: you need to figure out a way
to make these minimal cases not explode in a shower of ugly:
"let x = 10;" // Simple let
"let (x,y) = foo();" // Destructuring let
"match x { Red => 1, Green => 2 }" // Ctors alone
"match x { Foo {a, b} => a+b, _ => 2 }" // Ctors with destructuring
"match x { Foo {ref a, ..} => z }" // &-based destructuring
They work today, but only at the cost of some resolution-ambiguity
between constructors and captures. And they don't handle matching named
constants (thought this could probably be shoved back to "working" if we
changed the resolution disambiguation rule a bit).
It's a super cramped space. Everyone wants to be in sigil-free,
qualifier-free position. We've been struggling with the tradeoffs here
for nearly a year and a half, but by all means, keep trying to arrange
it into a tighter bundle than we've got.
As for lambda ... well, there's quite a variety to pick from:
http://rigaux.org/language-study/syntax-across-languages/Fnctn.html#FnctnnnmsFnct
I'm finding ours works well, particularly given the integration with our
block-forms, which are probably the main use-case. The block-head is
usually already pretty cramped on a line, which is why we went with the
"very minimal" form we have now.
-Graydon
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev