Hi.
I’d just like to get clarification on a few points which I haven’t seen explicitly spelled out in the docs.
(1 - I’ve seen checks for object validity such as:
if object.removeSelf ~= nil then -- make sure display object hasn't been removed
Can that be relied upon?
I’d always been checking against parent , but that seems to have become less robust: snapshots’ groups, for instance, have no parent yet may still be alive and kicking. This hasn’t caused me any problems (yet?), but obviously isn’t quite right.[1]
(2 - Does display.remove () do any such check? The docs only mention the case where the argument is nil , so I’ve always hewed to that.
(3 - In the simulator at least, it seems that although the removeSelf and parent properties are nil following a call like removeSelf (), others such as x and y can still be looked up, not becoming inaccessible until a subsequent frame.
Are there (or could there be) any guarantees about this? If it does indeed work now–and I’m not just getting lucky–might it break down the road?[2]
In particular, I’m wondering about “finalize” listeners, one of the more obvious places to grab an arbitrary object’s final state. Event dispatch seems to occur after the actual remove ( removeSelf and parent are already gone, anyway), so I’m concerned that querying the remaining properties might be hit-or-miss.
If it turns out there’s nothing to worry about, I could tidy up more than a few paranoid bits of code. 
Thanks!
[1] -
That said, it _was _fine for quite a long time (despite relying on something of an educated guess), until the then-new G2.0 features undermined certain assumptions. It’s not inconceivable that something similar could happen with removeSelf , say if the method was outright removed from objects like the stage or the aforementioned snapshot groups, where its only real purpose would be to service the check in question.
Incidentally, I could see this being a common enough need to warrant a display.isValid () predicate in Corona itself, even if it’s something dead simple–like the code above–under the hood. (The name comes courtesy of such a function available in roaminggamer’s SSK.)
[2] -
If I’m not mistaken, the display object properties were indeed wiped immediately, not so very long ago. But I imagine the newer behavior is meant to improve SDK stability, which suggests it might be here to stay.

In a couple of places I stumbled across a numChildren property that’s nil despite removeSelf still being present. In both instances, the problem code is inside a timer. For whatever reason, in these circumstances, removeSelf never disappears.