Maurice Lombardi wrote:
Frank Heckenbach a écrit :
Maurice Lombardi wrote:
But again, that wasn't my point. If you have a (say, TP style) object that declares a destructor "Done", in none of the cases it will be called automatically:
If the object is on the stack and leaves scope, and you don't call the destructor manually ("Foo.Done").
If the object is dynamic and you dispose of it simply with "Dispose (Foo)" rather than "Dispose (Foo, Done)".
If the object is dynamic and its memory is reclaimed, e.g., by the Boehm GC (which doesn't know about objects at all, just memory blocks).
In contrast, in C++ in the first two cases the destructor is called automatically
No plan to implement this in gpc, with an additional compiler option if you do not like to make this behavior the default for gpc ?
It would rather be a different object model: TP and OOE (and I think also Delphi) objects can have several destructors, and destructors with parameters. For automatic destructor calls, you need to have a single destructors without parameters (or at least a designated default destructor). IMHO, that's no big restriction (even with TP style objects, I almost always use a single parameterless destructor anyway), but it doesn't fit well with the existing models.
Frank