--- Comment #8 from Kenji Hara <> 2011-07-27 13:02:34 PDT ---
(In reply to comment #7)
> Yes, clearly that is a good path.
> But my question is, why __dtor not the same as destroy?  Is there any reason 
> to
> call ~this() without calling all the sub-dtors?

Basically the name "__dtor" is beginning with double underscores, so it is
internal name. At least calling it is not "Right D Way", I think.

(This point is different from C++ syntax: T t(); t.~T();)

> In my opinion, ~this() should implicitly contain the __dtors for all the
> members at the end.

Looking at dmd source, the internal function name for its purpose may be
"__fieldDtor" or "__aggrDtor", but we can't call them explicitly.

> But yes, having clear use typeid().destroy will fix the original symptom.  If
> we don't intend to fix the root cause, we should at least document that nobody
> should ever use __dtor...

Agreed. Today calling __dtor is obviously incorrect idiom.

extern(C) int printf(const(char*) fmt, ...);
struct X
  ~this(){ printf("X.~this()\n"); }
struct S
  X x;
  ~this(){ printf("S.~this()\n"); }
void main()
  S s;

S.~this()    // s.__dtor() only call S.~this(), never call s.x.~this()

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to