[rust-dev] names needed for function types

Brian Anderson banderson at mozilla.com
Sun Jan 1 13:32:17 PST 2012



----- Original Message -----
> From: "Niko Matsakis" <niko at alum.mit.edu>
> To: "Brian Anderson" <banderson at mozilla.com>
> Cc: rust-dev at mozilla.org
> Sent: Sunday, January 1, 2012 9:37:26 AM
> Subject: Re: [rust-dev] names needed for function types
> 
> > Here is how it would look with square brackets:
> 
> It occurs to me that the "capture clause" could (and probably should)
> go
> before the name, if we allowed it on nested fn item declarations:
> 
>      fn no_env(a: A, b: B) {...}
>      fn<copy> boxed_env_1(a: A, b: B) {...}
>      fn<copy a; move b> boxed_env_2<A,B>(a: A, b: B) {...}
>      fn<send; copy a; move b> unique_env<A,B>(a: A, b: B) {...}
> 
> In this way there is no ambiguity at all.  (Note that we don't allow
> function types to have generic parameters at the moment)
> 

I was thinking that 'copy' and 'send' are kind bounds that apply to the environment instead of a parameter, so it would make sense to write

    fn boxed_env_1<copy>(...) { ... }
    fn boxed_env_2<copy, copy A, send B>(a: A, b: B) { ... }

The capture clause seems like a different kind of thing, so could still use [].


More information about the Rust-dev mailing list