On Sat, Jan 12, 2013 at 1:21 PM, James Gao <gaoz...@gmail.com> wrote:
> and how about these two case:
>
> a) fn foo<T1: Ord, Eq, Hash; T2: Ord, ::Eq> (...) {...}

I think that a problem with using semicolon as the delimiter between
trait type parameters (i.e., between `T1: X` and `T2: Y`) is that it
would differ subtly and unexpectedly from the use of comma in function
definitions and structures (i.e., "everywhere else").

As a result, you would have:
        fn f(a: X, b: Y) ...
        struct Z {a: X, b: Y}
versus:
        fn foo<T2: X; T2: Y> ...

> b) fn foo<T1: Ord + Eq + Hash, T2: Ord + ::Eq> (...) {...}

Similarly to `+`, perhaps `|` or `&` could make sense as the delimiter
between trait bounds within a single type variable, if you interpret
(or define) the combination of trait bounds as a set operation:
either "the union of the constraints specified by the bounds" or
"the intersection of types that meet the constraints".

        fn foo<T1: Ord | Eq | Hash, T2: Ord | ::Eq> (...) {...}
        fn foo<T1: Ord & Eq & Hash, T2: Ord & ::Eq> (...) {...}

jb


> On Sat, Jan 12, 2013 at 6:27 AM, Gareth Smith <garethdanielsm...@gmail.com>
> wrote:
>>
>> On 11/01/13 18:50, Niko Matsakis wrote:
>>>
>>>
>>> fn foo<T:Eq>(..) {...} // One bound is the same
>>> fn foo<T:(Ord, Eq, Hash)>(...) {...} // Multiple bounds require
>>> parentheses
>>
>>
>> How about using { ... } rather than ( ... ), like imports:
>>
>> use xxx::{a, b, c};
>>
>> fn foo<T:{Ord, Eq, Hash}>(...) { ... }
>>
>> I don't know that this is better but maybe it is worth considering?
>>
>> Gareth.
>>
>> _______________________________________________
>> Rust-dev mailing list
>> Rust-dev@mozilla.org
>> https://mail.mozilla.org/listinfo/rust-dev
>
>
>
> _______________________________________________
> Rust-dev mailing list
> Rust-dev@mozilla.org
> https://mail.mozilla.org/listinfo/rust-dev
>
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to