On 2015-02-25 22:06, deadalnix wrote:
Here is something I've noticed going on various time, recently in the
memory management threads, but as to avoid an already heated debate,
I'll use enum types as an example.

We have a problem with the way enums are defined. If you have :

enum E { A, B, C }
E e;

We have (1)
final switch(e) with(E) {
     case A:
         // ...
     case B:
         // ...
     case C:
         // ...
}

But also have (2):
typeof(E.A | E.B) == E

How about allowing something like this:

enum E : void { A, B, C }

The above would disallow use case (2). The compiler would statically make sure a variable of type "E" can never have any value other than E.A, E.B or E.C.

This should be completely backwards compatible since the above syntax is currently not allowed. It also doesn't introduce a new type, at least not syntactically.

--
/Jacob Carlborg

Reply via email to