digitalmars.D - Inconsistent attribute propagation?
- Neia Neutuladh (25/25) Dec 01 2018 I noticed inconsistency with how builtin attributes propagate into types...
- bauss (9/36) Dec 02 2018 Not sure if intentional or not, but usual you'd do it like this:
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() {}
}
Dec 01 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() {}
}
Dec 02 2018








bauss <jj_1337 live.dk>