[rust-dev] bikeshed on closure syntax

Jeff Schultz jws at csse.unimelb.edu.au
Wed Apr 18 17:07:36 PDT 2012

On Wed, Apr 18, 2012 at 08:14:01AM -0700, Patrick Walton wrote:
> And change BlockLambda to:

>     BlockLambda ::== '->' Expr
>                    | '|' InferredArg (',' InferredArg)* '|' Expr

> 1. Bars indicate a closure.

> 2. A thin arrow indicates a zero-argument thunk.

Any reason we can't just have an empty '||' instead of the '->'?

It's easier to type and makes it easier to find all closures.

> 3. In any function call, trailing closure arguments can be pulled out and 
> placed after a colon. If this is done, the semicolon statement separator 
> after the call can be omitted.

Why is the ':' needed?

    Jeff Schultz

More information about the Rust-dev mailing list