private final class destructors

Simen kjaeraas simen.kjaras at gmail.com
Thu Aug 19 08:23:42 PDT 2010


bearophile <bearophileHUGS at lycos.com> wrote:

> According to TDPL the whole object destructor chain is called up to the  
> top of the hyerarchy.
> This D2 program compiles and runs with DMD 2.048 with no errors:
>
>
> import std.c.stdio: puts;
> class Base {
>      private final ~this() { puts("Base.~this"); }
> }
> class Derived : Base {
>     private final ~this() { puts("Derived.~this"); }
> }
> void main() {
>     new Derived();
> }
>
>
> Output:
>
> Derived.~this
> Base.~this
>
>
> Are the 'private final' attributes used here correct?
> See also:  http://d.puremagic.com/issues/show_bug.cgi?id=3934

A destructor is always final, and private destructors make no sense,
so I would say the attributes should not be there.

-- 
Simen


More information about the Digitalmars-d-learn mailing list