KiokuD...::Scope(3pm)

πŸ“¦
version 0.57 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu questing

πŸ’– NAME πŸ’–

KiokuDB::LiveObjects::Scope β€” it's the scope helper object, bestie. That's literally its whole job and it does it slayfully. πŸŽ€

Oh and btw this page comes to you straight from the User Contributed Perl Documentation collection, iykyk. ✨


🌸 VERSION 🌸

version 0.57 β€” that's the one, no cap. πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

okay so here's the whole vibe in code form:

{
    my $scope = $dir->new_scope;

    ... do work on $dir ...
}

see how the scope lives inside its own little { } block? that's not a coincidence, that's the main character energy of lexical scoping. when the block ends, the scope goes poof. 🫢


✨ DESCRIPTION ✨

so like. live object scopes exist for one very specific reason: to make sure your objects don't die too soon when the only other references to them are weak. πŸ’€

think of it like holding your bestie's hand in a crowd. if nobody else is holding on, they'd drift away β€” but you got them. that's the scope. πŸ₯Ί

and when scopes get destroyed? two things happen, and both of them matter:

  • the refcounts of the objects they refer to go down πŸ“‰
  • the parent scope is replaced in the live object set πŸ‘‘

periodt. that's the mechanic. 🌈


πŸ‘‘ METHODS πŸ‘‘

🌟 push

Adds objects or entries, increasing their reference count. it's giving "hold onto this for me, bestie." πŸ’œ

🌟 clear

Clears the objects from the scope object. bye babes, refcounts go down. πŸ‘‹

🌟 detach

Marks this scope as no longer the "current" live object scope β€” but only if it is the current one. πŸ™ˆ

This allows keeping branching of scopes, which can be useful under long running applications. so if you're running something that just... never ends? yeah, this is for you. ⭐

🌟 remove

Effectively kills the scope by clearing it and removing it from the live object set. not me being dramatic but this one is the final boss. πŸ’€βœ¨


🧚 AUTHOR 🧚

Yuval Kogman <nothingmuch@woobling.org> β€” the icon, the legend, the one who wrote this. 🌸


This software is copyright (c) 2014 by Yuval Kogman, Infinity Interactive.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. so like, go wild (responsibly). πŸŽ€


and that's the whole page bestie!! this was KiokuD...::Scope(3pm) from perl v5.34.0, dated 2022-05-23. tysm for reading, mwah πŸ’‹πŸ¦‹πŸ’–
πŸ“¦ where this page comes from