clear()

grauzone none at example.net
Fri Oct 9 13:08:09 PDT 2009


Andrei Alexandrescu wrote:
> I'm talking with Sean and Walter about taking the first step towards 
> eliminating delete: defining function clear() that clears the state of 
> an object. Let me know of what you think.
> 
> One problem I encountered is that I can't distinguish between a default 
> constructor that doesn't need to exist, and one that was disabled 
> because of other constructors. Consider:
> 
> class A {}
> class B { this(int) {} }
> 
> You can evaluate "new A" but not "new B". So it's legit to create 
> objects of type A all default-initialized. But the pointer to 
> constructor stored in A.classinfo is null, same as B.
> 
> Any ideas?

So, after wondering why Object.factory() can instantiate objects even if 
these objects have no constructor, I read the Phobos documentation (I 
mean... I read the source, it wasn't in the docs), I found this:

  uint        flags;
     //  1:      // is IUnknown or is derived from IUnknown
     //  2:      // has no possible pointers into GC memory
     //  4:      // has offTi[] member
     //  8:      // has constructors
     // 16:      // has xgetMembers member
     // 32:      // has typeinfo member

Yes, flag 8 is exactly what you want.



More information about the Digitalmars-d mailing list