Should compilers take advantage (abuse) of the new UDA syntax that has been accepted?

Peter Alexander peter.alexander.au at gmail.com
Tue Dec 18 08:43:52 PST 2012


On Tuesday, 18 December 2012 at 15:19:58 UTC, Iain Buclaw wrote:
> Should we take this as an opportunity for other compiler 
> maintainers to implement their own compiler-specific predefined 
> attributes?

Please, no!

Suppose GDC implements @noreturn (or whatever other attribute)

Later, LDC implements @noreturn separately with slightly 
different semantics.

We now end up in a situation where @noreturn cannot be used 
portably, and neither compiler developer has incentive to change 
(whoever changes breaks their users code).

To make matters worse, due to the lack of preprocessor in D, 
there's no easy way to work around it (mixins work, but are quite 
ugly).

Finally, if we want to add @noreturn to the spec then it will be 
forced to match the behaviour of the compilers than jumped the 
gun (if you don't then you force those compilers to change their 
implementations to match the spec, breaking their users code that 
already depends on it).

If you do want to add your own attributes then please use names 
like __noreturn, or even __gdc_noreturn so that you don't prevent 
standardised usages being added to the spec.



More information about the Digitalmars-d mailing list