with-disposal ( object quot -- )
Factor documentation > Factor handbook > The language > Deterministic resource disposal > Using destructors
Prev:dispose ( disposable -- )
Next:dispose-each ( seq -- )


Vocabulary
destructors

Inputs and outputs
objecta disposable object
quota quotation with stack effect ( object -- )


Word description
Calls the quotation, disposing the object with dispose after the quotation returns or if it throws an error.

Definition
USING: continuations kernel ;

IN: destructors

: with-disposal ( object quot -- )
over [ dispose ] curry [ ] cleanup ; inline