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.
Scope::Guard
$callback is set to the "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.
SPVM::Scope::Guard
Copyright (c) 2023 Yuki Kimoto
MIT License
To install SPVM, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SPVM
CPAN shell
perl -MCPAN -e shell install SPVM
For more information on module installation, please visit the detailed CPAN module installation guide.