Bug 3999 and 4261

bearophile bearophileHUGS at lycos.com
Wed Sep 1 15:03:39 PDT 2010


Andrei:

> I think it's a good enhancement.

Good :-)


> C++'s good old enum has been 
> instrumental in finding a few bugs and clarifying a few interfaces in a 
> project at work. Based on that experience I'd say that there's a chance 
> more restrictive is better.

There is also the experience of the C++0x group of designers, and their "enum class". One of the purpose of those "enum class" is to remove implicit conversions to int:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1719.pdf


> We need to find a principled way to define 
> semantics though - if we disable comparison it really means we're 
> disabling implicit conversion.

I agree.

If bug bug 3999 gets accepted in the form I meant, then probably the bug 4261 too may be considered, because then enums aren't "ints" and the most natural way to print them on default is by name and not by hidden representation value:
http://d.puremagic.com/issues/show_bug.cgi?id=4261


> It's bound to break some code.

Yes, several of the about 25 entries of my 'short list' I have recently shown here are able to break some code. This is why I am showing them here now. I think of those bug reports are more "important" than the others I have put in Bugzilla because as more and more D2 code gets written, even tiny breaking changes become harder and harder to justify.

Bye,
bearophile


More information about the Digitalmars-d mailing list