SPVM::Scope::Guard − Executing Callback at End of Scope
use
Scope::Guard;
# Executing the callback at the end of the scope
{
Scope::Guard−>new(method : void () {
print "End of Scope\n";
});
print "Foo";
}
# With field definitions
{
my $value = 1;
Scope::Guard−>new([$value : int] method : void () {
print "$value\n";
});
print "Foo";
}
The Scope::Guard class has the methods to execute a callback at the end of the scope.
"has callback : ro Callback;"
A callback called at the end of the scope.
"static method new : Scope::Guard ($callback : Callback);"
Creates a new "Scope::Guard" object and returns it.
$callback is set to "callback" field.
Exceptions:
$callback must be defined. Otherwise an exception is thrown.
"method DESTROY : void ();"
Executes the "callback".
"SPVM::Scope::Guard" is a port of Perl's Scope::Guard to SPVM.
Copyright (c) 2023 Yuki Kimoto
MIT License