Closeable
Interface Closeable
| Method Prototype | Description
|
| Sub Close() | close this item (whatever that means)
|
It's a reasonably common pattern to have a set of objects which need to do some cleanup when they are no longer needed. Normally, such cleanup should be done in the destructor, but if the objects may contain circular references, then the destructors would never fire.
The common solution in such cases is to have a "Close" method, whose job it is to clear all references to other objects, thus breaking the circular references and allowing the objects to be disposed of properly.
The Closeable class interface has been defined to represent this common pattern. Any object which needs a Close method should declare that it implements Closeable. This will allow you to, for example, maintain an array of Closeable objects, and iterate through them at the end of your script, calling Close on each one.
It is important to note that this is not done for you automatically — that is, implementing Closeable does
not cause the Close method to be called for you. You still have to do that yourself.
Framework classes that implement Closeable include:
Database,
RecordSet,
TextOutputStream,
TextInputStream, and
BinaryStream.