On 3/22/13 4:51 PM, Patrick Walton wrote:
* `::` will show up for many casual uses of enums. e.g.

     enum Color { Red, Green, Blue }
     fn main() {
         let x = Color::Red;
         match x {
             Color::Red => ...
             Color::Green => ...
             Color::Blue => ...
         }
     }

The more I think about this, the more I dislike the chattiness here. No other functional language that I know of namespaces variants under the sum type. Also notice how if you consider this analogous to object-oriented inheritance (like Scala `case class`), it's somewhat strange; Red, Green, and Blue are just "subtypes" of Color, and subtyping doesn't imply namespacing.

Maybe C++11 actually did the right thing with having two forms. strcat suggested `enum mod` to opt in to namespacing the variants under the enum. That would be backwards compatible.

Patrick

_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to