Variables should have the ability to be @nogc

Basile B. via Digitalmars-d digitalmars-d at puremagic.com
Tue May 31 13:41:09 PDT 2016


On Tuesday, 31 May 2016 at 19:04:39 UTC, Marco Leise wrote:
> Am Tue, 31 May 2016 15:53:44 +0000
> schrieb Basile B. <b2.temp at gmx.com>:
>
>> This solution seems smarter than using the existing '@nogc' 
>> attribute. Plus one also for the fact that nothing has to be 
>> done in DMD.
>
> I just constrained myself to what can be done in user code from 
> the start. :)
>
>> Did you encounter the issue with protected and private members 
>> ?
>> 
>> For me when i've tested the template i've directly got some 
>> warnings. DMD interprets my 'getMember' calls as a deprecated 
>> abuse of bug 314 but in dmd 2.069 I would get true errors.
>
> Actually it is in a large half-ported code base from C++ and I 
> haven't ever had a running executable, nor did I test it with 
> recent dmd versions. My idea was to mostly have @nogc code, but 
> allow it for a transition time or places where GC use does not 
> have an impact. Here is the code, free to use for all purposes.

Thx for sharing the template. When using '.tupleof' instead of 
the traits 'allMember'/'getMember' there's no issue with the 
visibility, which is awesome. It means that the template can be 
proposed very quickly in phobos.

The only thing is that I'm not sure about is the tri-state and 
the recursion. I cannot find a case where it would be justified.




More information about the Digitalmars-d mailing list