Re: [rust-dev] Bounds on type variables in structs, enums, types

2014-03-26 Thread comex
On Tue, Mar 25, 2014 at 8:29 PM, Nick Cameron li...@ncameron.org wrote: I made an RFC - https://github.com/rust-lang/rfcs/pull/20 In my half-baked opinion, it's nice to put bounds on a struct rather than its impl(s), so that nonsensical specializations cannot be created, rather than being

Re: [rust-dev] Bounds on type variables in structs, enums, types

2014-03-26 Thread Nick Cameron
We could allow bounds to be locally inferred. E.g., `implX TX for SX { ... }` would infer the lub of bounds from T and S for X. But since we can have an impl for any type, not just a struct, I think the general case might be too tricky to do inference for. We might also want to take into account

Re: [rust-dev] Bounds on type variables in structs, enums, types

2014-03-25 Thread Patrick Walton
On 3/24/14 11:46 PM, Nick Cameron wrote: Currently we forbid bounds on type parameters in structs, enums, and types. So the following is illegal: struct SX: B { f: ~TX, } IIRC Haskell allows bounds on type parameters (and we did once too), but I heard that considered deprecated and not

Re: [rust-dev] Bounds on type variables in structs, enums, types

2014-03-25 Thread Matthieu Monrocq
On Tue, Mar 25, 2014 at 6:00 PM, Patrick Walton pcwal...@mozilla.comwrote: On 3/24/14 11:46 PM, Nick Cameron wrote: Currently we forbid bounds on type parameters in structs, enums, and types. So the following is illegal: struct SX: B { f: ~TX, } IIRC Haskell allows bounds on type

Re: [rust-dev] Bounds on type variables in structs, enums, types

2014-03-25 Thread Nick Cameron
Thanks for the info! Sized will be going away very soon, but it will be replaced by 'unsized' (or something with the same semantics), so we have exactly the same question. I don't understand the HashMap example (I'm thinking in Rust terms, and perhaps you meant it to be a Haskell example, I'm not

Re: [rust-dev] Bounds on type variables in structs, enums, types

2014-03-25 Thread Nick Cameron
The removal was in https://github.com/mozilla/rust/pull/4660, but there is no discussion of why. Do you recall who promoted the change? I fear it makes the syntax simpler, but the language more complex and surprising. On Wed, Mar 26, 2014 at 6:00 AM, Patrick Walton pcwal...@mozilla.comwrote: