Re: [rust-dev] RFC: Remove custom enum variant discriminants

2013-03-01 Thread Benjamin Striegel
So then the only changes to existing code would be: 1) Wrapping the enum definition in a macro and giving it a type. 2) Changing `foo as bar` to `foo.to_bar()`. Is this correct? Here's an example that I've modified with the new syntax: https://gist.github.com/bstrie/5064858 . It looks pretty

Re: [rust-dev] RFC: Remove custom enum variant discriminants

2013-03-01 Thread Niko Matsakis
Interesting idea. I'm generally in favor of moving things out of the core language. What makes me hesitate a bit here is that it would be nice if one could translate C types into Rust types that are then representation-compatible so as to ease interoperability. If we take this proposal, any C

Re: [rust-dev] RFC: Remove custom enum variant discriminants

2013-03-01 Thread Graydon Hoare
On 13-02-28 09:18 PM, Patrick Walton wrote: There is currently a feature whereby custom enum variant discriminants can be specified: pub enum Foo { Bar = 1, Baz = 2, Boo = 3, } The sole use of this is casting from the enum to an int: It's also to

Re: [rust-dev] RFC: Remove custom enum variant discriminants

2013-03-01 Thread Patrick Walton
On 3/1/13 11:51 AM, Graydon Hoare wrote: It's also to represent enums known-to-C++ with the same values when projected into rust types. It'll always be a less-than-faithful translation, though, because C++ enum values don't have to correspond to any of the variants. You can even represent

[rust-dev] RFC: Remove custom enum variant discriminants

2013-02-28 Thread Patrick Walton
Hi everyone, There is currently a feature whereby custom enum variant discriminants can be specified: pub enum Foo { Bar = 1, Baz = 2, Boo = 3, } The sole use of this is casting from the enum to an int: println(fmt!(%d, Bar as int)); // prints 1 This