[rust-dev] bikeshed on closure syntax
niko at alum.mit.edu
Wed Apr 18 06:48:01 PDT 2012
On 4/17/12 10:03 PM, David Piepgrass wrote:
> > This requires arbitrary lookahead to disambiguate from tuples.
> This bit in particular. Really really don't want to cross the
> bridge to
> arbitrary lookahead in the grammar.
> Pardon me, but I'm not convinced that there is a problem in lambdas
> like (x, y) -> (x + y). By analogy, you can realize that ((x * y) + z,
> q) is a tuple instead of a simple parenthesized expression when you
> reach the comma -- you don't need to look ahead for a comma in
> advance. So why not treat (x, y) as a tuple until you reach the "->"
> and then reinterpret the contents at that point? This works as long as
> the syntax of a lambda argument list is a subset of the tuple syntax,
> anyway. If that's not the case, parsing gets messier, though I'm sure
> arbitrary lookahead is not be the only possible implementation.
You are correct that, in theory, we could parse, but we wouldn't be able
to build AST nodes until we know definitively whether it's a lambda or not.
More information about the Rust-dev