NAME
std/defer - Run a callback when a guard object is demolished.
SYNOPSIS
from std/defer import Guard;
let guard := new Guard( callback: fn () { cleanup(); } );
guard.disable();
IMPLEMENTATION SUPPORT
This module is supported by all implementations of ZuzuScript.
DESCRIPTION
Guard is a small scope guard. It stores a callback and can be armed or disarmed before demolition.
EXPORTS
Classes
Guard({ callback: Function, armed?: Boolean })Constructs a guard that calls
callbackwhen the object is demolished. The guard starts armed unlessarmedis supplied as false.guard.enable()Parameters: none. Returns:
null. Arms the guard so demolition will run the callback.guard.disable()Parameters: none. Returns:
null. Disarms the guard so demolition will not run the callback.
COPYRIGHT AND LICENCE
std/defer is copyright Toby Inkster.
It is free software; you may redistribute it and/or modify it under the terms of either the Artistic License 1.0 or the GNU General Public License version 2.