Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: Tie & Destroy, OOP

by mothra (Hermit)
on Aug 10, 2001 at 17:17 UTC ( #103862=note: print w/replies, xml ) Need Help??

in reply to Tie & Destroy, OOP

The real problem here is that you're relying on a destructor to do real cleanup work. That's not a good idea because a.) destructors don't always get reliably called, b.) it's possible that you may end up referring to objects in your destructor that have already been destroyed (*ahem* :).

A destructor should be more of a "backup plan" that calls your "cleanup" routine a second time. That is, your "cleanup" rountine should be called at least once by you, and be written in such a way that it won't blow up if it gets called twice (because many times it will get called a second time by your "backup"..the destructor).

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://103862]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2022-05-22 12:07 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (80 votes). Check out past polls.