DIP60: @nogc attribute

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Thu Apr 17 05:04:27 PDT 2014


On Wed, 16 Apr 2014 13:39:36 -0400, Walter Bright  
<newshound2 at digitalmars.com> wrote:

> On 4/16/2014 1:49 AM, "Ola Fosheim Grøstad"  
> <ola.fosheim.grostad+dlang at gmail.com>" wrote:
>> Btw, I think you should add @noalloc also which prevents both new and  
>> malloc. It
>> would be useful for real time callbacks, interrupt handlers etc.
>
> Not practical. malloc() is only one way of allocating memory - user  
> defined custom allocators are commonplace.

More practical:

Mechanism for the compiler to apply arbitrary "transitive" attributes to  
functions.

In other words, some mechanism that you can tell the compiler "all the  
functions this @someattribute function calls must have @someattribute  
attached to it," that also applies the attribute automatically for  
templates.

Then, you can come up with whatever restrictive schemes you want.

Essentially, this is the same as @nogc, except the compiler has special  
hooks to the GC (e.g. new) that need to be handled. The compiler has no  
such hooks for C malloc, or whatever allocation scheme you use, so it's  
all entirely up to the library and user code.

-Steve


More information about the Digitalmars-d mailing list