crystal clear()

Steven Schveighoffer schveiguy at yahoo.com
Fri Sep 17 15:07:34 PDT 2010


On Fri, 17 Sep 2010 17:59:15 -0400, Andrei Alexandrescu  
<SeeWebsiteForEmail at erdani.org> wrote:

> On 09/17/2010 04:55 PM, Steven Schveighoffer wrote:
>> On Fri, 17 Sep 2010 17:33:11 -0400, Andrei Alexandrescu
>> <SeeWebsiteForEmail at erdani.org> wrote:
>>
>>> I think clear() can be fixed if we remove the call to the constructor
>>> AND obliterate the vptr.
>>
>> agreed.
>>
>>> In fact ideally we'd obliterate all vptrs of the object, which might
>>> be tricky. Ideas?
>>
>> There's only one vptr, no?
>
> One global (at the beginning of the object) plus one per implemented  
> interface.

Oh right, I forgot that's necessary to allow interfaces to be  
single-pointer types.  Hm.. that seems like such a waste...  Too bad  
interfaces can't be fat pointers.

For our purposes, you should only have to zero out the main vptr, since  
that's where the destructor is.  But to help increase the loudness of  
errors on interface calls, you would have to zero out all the vptrs.  Is  
this difficult?  If necessary, we can add a traits directive, right?

-Steve


More information about the Digitalmars-d mailing list