The non allocating D subset

Simen Kjaeraas simen.kjaras at gmail.com
Fri Jun 7 08:22:04 PDT 2013


On Fri, 07 Jun 2013 17:01:27 +0200, Tyler Jameson Little  
<beatgammit at gmail.com> wrote:

> @nogc void foo() {} // #1
> @safe void foo() {}             // #2
>
> @nogc void baz() {
>      foo();
> }
>
> Which gets called when -safe is passed?

I'm not familiar with -safe, but in the example above #1 would be called,  
as
baz claims be @nogc, and thus that its callees are also @nogc. #1 fulfills
this requirement, #2 does not.

If in addition to @nogc baz was marked @safe, it would be a compile-time
error - there is no function foo that is both @safe and @nogc.

This is just like pure, @safe and nothrow today - if a function is pure
nothrow, it can not call a function that is only pure or only nothrow.

-- 
Simen


More information about the Digitalmars-d mailing list