Should compilers take advantage (abuse) of the new UDA syntax that has been accepted?
bearophile
bearophileHUGS at lycos.com
Tue Dec 18 07:48:09 PST 2012
Iain Buclaw:
> Where GDC has the following to allow developers to mark
> functions with the backend attribute 'noreturn'.
>
> pragma(attribute, noreturn)
> void die()
> {
> abort();
> }
>
>
> Potentially this can now be re-written as.
>
> void die() @noreturn
> {
> abort();
> }
>
>
> Would you guys stand for such a change to be allowed?
If it's an useful feature, then I suggest to integrate @noreturn
in d/dmd too.
If it's useful but Walter doesn't want it or it can't be
implemented in dmd, then I suggest to keep using the less common
pragma(attribute, noreturn) syntax in gdc, to not clash with
missing but potential D features.
Compiler-specific features should never clash with potential
future D features.
-------------
Regarding UDAs currently this program gives no warnings:
struct safe {}
@safe void foo() {}
void main() {}
But now foo is not tagged, it's a @safe function. To tag it you
have to use:
struct safe {}
@(safe) void foo() {}
void main() {}
Is this name clashing acceptable?
(This is also why adding @noreturn to gdc is a bad idea, increase
even more that confusion.)
Bye,
bearophile
More information about the Digitalmars-d
mailing list