John Carmack applauds D's pure attribute

Martin Nowak dawg at dawgfoto.de
Tue Feb 28 11:58:18 PST 2012


On Tue, 28 Feb 2012 09:30:12 +0100, Timon Gehr <timon.gehr at gmx.ch> wrote:

> On 02/27/2012 03:42 PM, Martin Nowak wrote:
> ...
>>>> https://gist.github.com/1920202
>>>
>>> Neat. Possible improvement (if I understand your code correctly):
>>> Don't add the GC range if all possible aliasing is through Ptr.
>>
>> I hope I did that.
>
> import smart_ptr;
>
> struct S{
>      Ptr!int a;
>      Ptr!double b;
> }
>
> static assert(hasAliasing!S);
>
All right, I would need a Ptr aware hasAliasing, that's true.
That's one of the few places where C++'s lookup rules for template
specializations are useful. std.traits.hasAliasing already has Rebindable  
hacks.

Either way I had an idea to split this into two parts.
- unique_ptr which handles ownership and destruction, could be  
Unique!(Scoped!T) as well.
- A move-on-shared wrapper, that has value semantics unless it gets  
shared, in which
   case the value is moved to a refcounted heap store.


More information about the Digitalmars-d mailing list