[dox] enum specs vs reality
captaindet
2krnk at gmx.net
Tue Aug 27 16:53:01 PDT 2013
i admit that i am not very good at reading/understanding language definition syntax. but yet i think the given enum specs ( http://dlang.org/enum.html ) are not quite in order.
they seem to imply that both
enum ;
enum WhatAmI ;
are correct. while the first one throws an error as expected, the second one passes and is partially usable, potentially similar to C's #define OPTION. however, typedef's throwing of an error makes me doubt that this is legal:
----
import std.stdio, std.traits;
enum test; // passes but is it really legal?
int main(string[] args)
{
writeln( __traits(compiles, test) ); // true
writeln( is( test == enum ) ); // true
writeln( isBasicType!(test) ); // true
writeln( isSomeFunction!(test) ); // false
// writeln( typeof(test).stringof ); // Error: argument test to typeof is not an expression
return 0;
}
More information about the Digitalmars-d
mailing list