next up previous contents index
Next: "list-alloc" and "list-free" Up: Changes and New Features Previous: New Class Syntax

"delete" Replaced by "free" and "zero-refs"

Don't worry, an instance is still deleted by calling the "delete" method on it, but to avoid problems with the refcount handling the delete mechanism has been changed.

The method "delete" now exists only on the base class Root, it cannot be defined for other classes (this will result in an error message). Instead of "delete" a class now has to define a method "free" which is called by Root "delete" when the instance is no longer needed and its variables can be freed. The refcount now is handled by Root "delete" (and "zero-refs", see below).

Converting existing "delete" methods to "free" methods is easy, just rename the methods from "delete" to "free", remove any code that checks or manipulates the refcount and call the superclass method "^free" instead of "^delete" at the end of the method.

"free" must neither check nor change the refcount, if you really need a special refcount handling (this is probably only the case when cyclic references are used as for TimeStep and Geom2d) you can define a "zero-refs" method which is then used by Root "delete" to determine if an object can be freed.

For further information and examples see sections 5.4.4.1 and 5.4.5.2.



SFB 256 Universität Bonn and IAM Universität Freiburg

Copyright © by the Sonderforschungsbereich 256 at the Institut für Angewandte Mathematik, Universität Bonn.