On Monday, 18 April 2016 at 19:57:42 UTC, cym13 wrote:

    @default = @safe @nogc @pure

    int foo(int i) { ... } // This function is @safe @nogc @pure
    int bar(int i) @pure { ... }  // This function is only @pure


Why not just put
@safe @nogc pure:
at the top? I feel like @default would really only help if you want to write
int foo(int i) @default { ... }

All things equal, I would probably prefer it as an alias
alias @default = @safe @nogc pure;

The biggest downside with this approach is that there's not enough attributes. For instance, you can't write
int bar(int i) @system @gc { ... }
While @system already exists, @gc doesn't. I believe this has also been discussed before on NG.

As an aside, the reason for not having function attribute inference everywhere is that it doesn't work when function bodies are not available. How common is this? I feel like I never write functions like this. Why not just make the rule that if the function body is available, then inference will happen?

Reply via email to