Inconsistent attribute propagation?
bauss
jj_1337 at live.dk
Sun Dec 2 12:19:01 UTC 2018
On Saturday, 1 December 2018 at 18:09:39 UTC, Neia Neutuladh
wrote:
> I noticed inconsistency with how builtin attributes propagate
> into types.
>
> The following propagate to member functions:
> * @safe
> * const
> * shared
> * immutable
> * linkage
>
> The following do not:
> * pure
> * @nogc
> * nothrow
>
> Is this intentional? I'm not seeing anything in the spec about
> it.
>
> Test code:
>
> import std.stdio;
> void main()
> {
> writeln(__traits(getFunctionAttributes,
> A.foo).stringof);
> writeln(__traits(getLinkage, A.foo));
> }
>
> @safe @nogc pure const shared nothrow extern(C)
> struct A
> {
> void foo() {}
> }
Not sure if intentional or not, but usual you'd do it like this:
struct A
{
@nogc:
...
void foo() {}
}
More information about the Digitalmars-d
mailing list