Thread overview | ||||||
---|---|---|---|---|---|---|
|
August 19, 2010 private final class destructors | ||||
---|---|---|---|---|
| ||||
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 Bye, bearophile |
August 19, 2010 Re: private final class destructors | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | bearophile <bearophileHUGS@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 |
August 19, 2010 Re: private final class destructors | ||||
---|---|---|---|---|
| ||||
Posted in reply to Simen kjaeraas | Simen kjaeraas:
> A destructor is always final, and private destructors make no sense, so I would say the attributes should not be there.
Thank you for your answer, I have added the test case to bug 3934
Bye,
bearophile
|
August 19, 2010 Re: private final class destructors | ||||
---|---|---|---|---|
| ||||
Posted in reply to Simen kjaeraas | On Thursday, August 19, 2010 08:23:42 Simen kjaeraas wrote:
> A destructor is always final, and private destructors make no sense, so I would say the attributes should not be there.
Actually, I could see private destructors making at least some sense. Obviously, the runtime needs to be able to call them, but I could see someone wanting to make it so that a destructor could not be explicitly called by the programmer. I'm not sure that that's ultimately all that useful, but I could see private destructors working that way.
- Jonathan M Davis
|
Copyright © 1999-2021 by the D Language Foundation