DIP60: @nogc attribute
Rikki Cattermole via Digitalmars-d
digitalmars-d at puremagic.com
Thu Apr 17 03:56:20 PDT 2014
On Thursday, 17 April 2014 at 10:38:54 UTC, Artur Skawina via
Digitalmars-d wrote:
> On 04/17/14 11:33, Rikki Cattermole via Digitalmars-d wrote:
>> On Thursday, 17 April 2014 at 09:22:55 UTC, Dejan Lekic wrote:
>>> On Tuesday, 15 April 2014 at 17:01:38 UTC, Walter Bright
>>> wrote:
>>>> http://wiki.dlang.org/DIP60
>>>>
>>>> Start on implementation:
>>>>
>>>> https://github.com/D-Programming-Language/dmd/pull/3455
>>>
>>> This is a good start, but I am sure I am not the only person
>>> who thought "maybe we should have this on a module level".
>>> This would allow people to nicely group pieces of the
>>> application that should not use GC.
>>
>> Sure it does.
>>
>> module mymodule;
>> @nogc:
>>
>> void myfunc(){}
>>
>> class MyClass {
>> void mymethod() {}
>> }
>>
>>
>> Everything in above code has @nogc applied to it.
>> Nothing special about it, can do it for most attributes like
>> static, final and UDA's.
>
> It does not work like that. User defined attributes only apply
> to
> the current scope, ie your MyClass.mymethod() would *not* have
> the
> attribute. With built-in attributes it becomes more
> "interesting" -
> for example '@safe' will include child scopes, but 'nothrow"
> won't.
>
> Yes, the current attribute situation in D is a mess. No,
> attribute
> inference isn't the answer.
>
> artur
Good point yes, in the case of a class/struct its methods won't
have it applied to them.
No idea post manually adding it to start of those declarations
can be done. Either that or we need language changes.
@nogc
module mymodule;
@("something")
module mymodule;
Well it is a possible option for improvement. Either way, I'm not
gonna advocate this.
More information about the Digitalmars-d
mailing list