Not logged inOpenClonk Forum
Up Topic How are you using the RemoveObject-zeroes-variables feature?

This board is threaded (i.e. has a tree structure). Please use the Reply button of the specific post you are referring to, not just any random button. If you want to reply to the topic in general, use the Post button near the top and bottom of the page.

Post Reply
In Response to Günther

> Go through all possible places where there can be pointers and delete them?


That would be another option. It's not as bad as it sounds - we need to denumerate all those places anyway, so the code to loop through every C4Value is already written.

But I actually want to try simply keeping those objects around and refcounting them, like arrays or strings.

> I find myself doing plenty of those if (!obj) return;- sanity checks. I do not like the idea of keeping pointers to dead objects, because that smells like trouble.


Well, my proposal would allow you to get rid of a lot of those sanity checks, because the dead object would still be around and you could do whatever you want with it. The engine has to support that today anyway, because the this pointer isn't cleared, so all engine functions already have to work on dead objects. The only sanity check needed is to ensure that the object hasn't teleported itself to 0/0 if that would affect stuff.

> If a pointer to the dead version of the object is kept, the object has to assume that functions in it are executed past the Destruction callback, so it has to assure the existence of the helper in every callback.


The helper object would stay around as long as the main object was kept around, so the main object would not need to check for it's existence. That's an improvement on the current situation, where the helper object could suddenly vanish completely without any warning.

So your stories seem to suggest that not zeroing objects would simply move the failure scenarios around. Interacting with dead objects certainly isn't the most tested corner case of the script interface, so the engine bugs would surface sooner. But as for script, whether one is surprised by a variable containing a dead object or a variable containing nil doesn't make a huge difference.

It might be too late to change this because a lot of script already relies on the current behaviour, but perhaps we can still make the change internally and hide it by making dead objects evaluate to false. Probably an experimental implementation to see what breaks is called for.

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill