How can I tell D that function args are @nogc etc.

John Dougan jdougan at acm.org
Thu Apr 11 03:17:36 UTC 2024


Interesting. Thank you to both of you.

On Wednesday, 10 April 2024 at 17:38:21 UTC, Steven Schveighoffer 
wrote:
> On Wednesday, 10 April 2024 at 11:34:06 UTC, Richard (Rikki) 
> Andrew Cattermole wrote:
>> Place your attributes on the right hand side of the function, 
>> not the left side.
>>
>> Use the left side for attributes/type qualifiers that go on 
>> the return type.
>
> Just a word of warning, this explanation suggests putting 
> qualifiers on the left side would affect the return type, this 
> is not the case.

So in my example, what did I actually tell the compiler with the 
placement of the attributes? And how was it different between the 
function type alias declaration, and the actual function 
declaration?

More specifically, what are the semantic differences below?
```d
alias FnPrefixT = @nogc nothrow @safe bool function(int);
// Versus
alias FnSuffixT = bool function(int) @nogc nothrow @safe;
```
and
```d
@nogc nothrow @safe bool fnPrefix(int) { stuff }
// Versus
bool fnSuffix(int) @nogc nothrow @safe  { stuff }
```
Is there a reasonably clear overview of how this works anywhere? 
What I have seen so far led me to the vague impression that it 
wasn't significant just like attribute ordering.

-- john





More information about the Digitalmars-d-learn mailing list