DIP68: Adding @nogc to types

Tomer Filiba via Digitalmars-d digitalmars-d at puremagic.com
Tue Nov 11 05:18:01 PST 2014


>> I'm not at all sure that how a type is allocated should be 
>> part of the type itself. There are an infinite way things can 
>> be allocated.
>
> Nitpick: it's about memory _management_, not _allocation_.

Exactly. I don't care much *where* the object lives, as long as 
it has deterministic properties.

> But the DIP is also underspecified. E.g., is it allowed to 
> embed a @nogc type in a class? If not, what if that class again 
> is wrapped in std.typecons.Scoped?

I thought I covered it there, but just to be clear, @nogc should 
be inherited by the containing type, so if a class has a @nogc 
member, the class itself becomes @nogc. For example:

@nogc struct Handle {...}
class Mandle {Handle shmandle;}

auto m1 = new Mandle(); // does not compile
scoped!Mandle m2;       // great success


-tomer


More information about the Digitalmars-d mailing list