On Wed, 16 Apr 2014 13:39:36 -0400, Walter Bright <[email protected]> wrote:

On 4/16/2014 1:49 AM, "Ola Fosheim Grøstad" <[email protected]>" 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

Reply via email to