C#/Java have destructors...
Posted Mar 30, 2005 10:57 UTC (Wed) by
pkolloch (subscriber, #21709)
In reply to:
OO is yesterday's news. by khim
Parent article:
Evidence that Python is advancing into the enterprise (NewsForge)
...but there are only guarantees to when they are not called. (Well, I have to admit that I have not dug deeply into this explicit GC control, but that's probably out of scope. In some circumstances even (managed) C# might even make some guarantees.)
In C#:
~TypeName() { ... }
In Java:
protected void finalize() throws Throwable() {...}
While I agree that you should not use that in pure managed code, it might make a lot of sense in wrappers to native code which allocates resources (which you want to deallocate automatically). In C# 2.0 you can even specify some kind of implicit cost for classes to provide meaningful heuristics for this case.
(
Log in to post comments)