Prev: TclOO: Is it possible that destructor is called on an object, but constructor is not?
Next: TclOO: Possible to "link" a member variable to a member variable of a different object?
From: George Petasis on 24 Jan 2010 11:48 στις 24/1/2010 18:39, O/H Donal K. Fellows έγραψε: > On 24 Jan, 11:00, Georgios Petasis<peta...(a)iit.demokritos.gr> wrote: >> Not an important problem, but I observe the following when an error occurs: > [...] >> These are widgets, and if an error is cause in another widget, objects >> are destroyed through Tk events. But since an object exists to call the >> destructor, this means that the constructor has ran, isn't it so? > > If the class was mixed into an instance, it would not have the > constructor called. If you are doing something complex with > inheritance and not using [next] in constructors somewhere, it is > possible for a constructor to get missed. (Unlike some languages, the > calling of [next] in the constructor is optional. In part, that's > because "constructors" don't actually make the object itself.) That's > not due to an inheritance error per se, but does indicate that > something you've been doing has gone wrong. > > It might be easier to rework the code so that it doesn't rely on the > variable existing; [info exists] is now a very cheap operation. > > Donal. I haven't yet used the "mixin" in my code, as it is not yet clear to me what it does. The class does not inherit anything also. What I did was to remove all checks, and leave only the catch around the object destruction. It is a cacth after all, if the variable is not defined, the object has not been cleated... It is possible that the object is destroyed before the constructor gets called, through a Tk event... George |