[dmd-internals] Keywords starting with __ and version identifiers
Alex
xtzgzorex at gmail.com
Thu Dec 29 03:56:07 PST 2011
Hi,
DMD currently has two keywords (AFAIK) starting with double
underscore: __traits and __gshared, and additionally, __ctfe (though
it isn't really a keyword)
>From what I can understand, they are implementation-dependent, and
thus not necessarily available in all compilers. This is reasonable
enough, but presently, there is no universal way to detect whether the
keywords are available. That means that any code that uses them simply
relies on the compiler having them, period. I don't think this is
optimal, nor is it good language design IMHO.
I think we need to have version identifiers that indicate whether they
are available, e.g.:
version (__traits)
{
enum compiles = __traits(compiles, { ... });
}
else
{
// Fall back to some other mechanism, perhaps some feature
provided by a non-DMD compiler...
}
Thoughts on this?
Regards,
Alex
More information about the dmd-internals
mailing list