Destroying Objects
BlitzMax Forums/BlitzMax Beginners Area/Destroying Objects
| ||
Is there any Method such as NEW that can be automaticaly invoqued just before an object is destroyed (reference count = 0) ??? If it's not, it should be a great improvement |
| ||
The method Delete( ). |
| ||
Thnxs!!! :) |
| ||
Hey, didn't know that :_) |
| ||
but it isn't guaranteed that it is called on collecting through the garbage collector. |
| ||
It's guaranteed that it's called, it's just not guaranteed when it's called ;) |
| ||
what possibilities are there for the when? Before or after the object is destroyed? ( the later one would be useless and result in feature call on null target ;) ) |
| ||
Delete() will always be called immediately before the object is destroyed - but you can't guarantee when it will be destroyed :) Actually, that's a bit of a lie. If you can guarantee that the object has no references you know it will be deleted at the next FlushMem, but if you rely on that behaviour one forgotten reference to the object will turn your game into debug hell. |