[rust-dev] bikeshed on closure syntax

David Piepgrass qwertie256 at gmail.com
Tue Apr 17 22:03:20 PDT 2012


>
> > 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.
-- 
- David
http://loyc-etc.blogspot.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20120417/eaa8b458/attachment.html>


More information about the Rust-dev mailing list