strong enums: why implicit conversion to basetype?

Trass3r un at known.com
Thu Jan 26 11:23:02 PST 2012


> `typedef' is or will be disallowed in D because of reasons I do not
> understand.

It's ill-defined. There are 4 possible types of typedef:  
http://d.puremagic.com/issues/show_bug.cgi?id=5467

> In C and C++ their existence introduce problems because
> they increase the amount of parsing passes.

C's typedef is equal to D's alias.

>> A named enum is a separate type with a finite set of allowed
>> values defined by the user.
> A)
> Both wrong according to the currently published reference:

Again, this thread is all about discussing the right way to do it and not  
about what the buggy and holey spec reads.

> 2) "Enum declarations are used to define a group of constants.", i.e. 
> only some of the valid values of the basetype are given names. All ofthe  
> valid values of the basetype are also valid

That's what anonymous enums are for.

> 3) "An EmptyEnumBody signifies an opaque enum - the enum members are
> unknown", i.e. none of the valied values of the basetype has got a
> name, but all valid values of the basetype are also valid in the type
> declared by the tag.

So the only purpose is to create a new type similar to typedef.
I don't see any merit in that.


More information about the Digitalmars-d mailing list