SPVM::Scope::Guard(3)

πŸ“¦ version 0.990125, in alpine 3.24

πŸŽ€ NAME πŸŽ€

okay bestie, welcome to the SPVM::Scope::Guard(3) page from the User Contributed Perl Documentation β€” and the whole vibe is literally Executing Callback at End of Scope. yes, we're doing cleanup-with-a-callback energy. πŸ’…βœ¨

✨ USAGE ✨

here's the group-chat demo, no cap:

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";
}

πŸ¦‹ DESCRIPTION πŸ¦‹

the Scope::Guard class has the methods to execute a callback at the end of the scope. that's the whole assignment, bestie. 🫢

🌸 FIELDS 🌸

🌷 callback 🌷

has callback : ro Callback;

a callback called at the end of the scope. that's it, that's the field. πŸŽ€

πŸ”₯ CLASS METHODS πŸ”₯

🫢 new 🫢

static method new : Scope::Guard ($callback : Callback);

creates a new Scope::Guard object and returns it. iconic behavior.

$callback is set to the callback field.

Exceptions: $callback must be defined. otherwise an exception is thrown. no cap β€” undefined callback = exception, so don't try it. πŸ’€

🧚 INSTANCE METHODS 🧚

πŸ’œ DESTROY πŸ’œ

method DESTROY : void ();

executes the callback. that's the whole method. periodt. πŸ’…

πŸ‘€ SEE ALSO πŸ‘€

  • Scope::Guard β€” SPVM::Scope::Guard is a port of Perl's Scope::Guard to SPVM.

Copyright (c) 2023 Yuki Kimoto

MIT License


byeee bestie πŸ«ΆπŸ’– this cutie was rendered from perl v5.42.2, dated 2026-02-03, and it's the SPVM::Scope::Guard(3) page. mwah πŸ’‹πŸŽ€

πŸ“¦ where this page comes from