Frank Heckenbach wrote:
Not really -- it's more for convenience (not having to check for nil before each Dispose; we might have let Dispose set to the pointer to nil afterwards as well if it was reliable; as has been pointed out in this thread, it's not).
There is no replacement in programming for the necessity of careful thinking with everything you do. There is no such thing like absolute "safety" against programming errors. In that regard, any discussion about "safety" is pointless. But, as Peter pointed out, defensive programming will help. Especially if accompanied with good design (for example, it should be crystal clear in the software who owns the pointer).
Regards,
Adriaan van Os