dispose ( disposable -- )
Factor handbook > The language > Deterministic resource disposal > Using destructors

Next:with-disposal ( object quot -- )


Inputs and outputs
disposablea disposable object

Generic word contract
Releases operating system resources associated with a disposable object. Disposable objects include streams, memory mapped files, and so on.

No further operations can be performed on a disposable object after this call.

Disposing an object which has already been disposed should have no effect, and in particular it should not fail with an error. To help implement this pattern, inherit from the disposable class and implement the dispose* method instead.

You must dispose of disposable objects after you are finished working with them, to avoid leaking operating system resources. A convenient way to automate this is by using the with-disposal word.

The default implementation assumes the object has a disposed slot. If the slot is set to f, it calls dispose* and sets the slot to t.


GENERIC: dispose ( disposable -- )