"default" keyword as function attribute
Jakob Ovrum via Digitalmars-d
digitalmars-d at puremagic.com
Sat Mar 19 11:39:54 PDT 2016
On Saturday, 19 March 2016 at 18:15:54 UTC, jmh530 wrote:
> On Saturday, 19 March 2016 at 15:09:00 UTC, Jakob Ovrum wrote:
>> Maybe an alternative would be to simply ignore explicit
>> attributes on templated functions
>
> That seems like a risky proposition. What if you mark some
> templates nogc to prevent inference on that. Then a future
> change causes an allocation. I would want to be notified.
Right. Any @nogc caller code would cease to compile, but maybe
the generic function is the entry point to a @nogc subportion of
the program.
As for the `default` approach, if we designed it to work with
explicit attributes, like so:
---
@safe:
void foo();
void bar(T)(T t) default @nogc; // Infer pure, nothrow and @safe
but require @nogc
---
Then `default` wouldn't have that problem.
More information about the Digitalmars-d
mailing list