List::...mutable(3pm)

πŸ“¦
version 2.028003 Β· 4 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

πŸ’– List::...mutable(3pm) πŸ’–

okay bestie so this is a page from the User Contributed Perl Documentation, and the manual name is List::...mutable(3pm) (yes the filename is literally truncated like that, it's giving mystery, it's giving ellipsis). sit down, hydrate, we're doing immutability 🫢


✨ NAME ✨

List::Objects::WithUtils::Role::Hash::Immutable β€” Immutable hash behavior. that's the whole vibe. the hash said "no notes, no edits, no takebacks." πŸ’…


🌸 SYNOPSIS 🌸

here's how you'd actually get one, via List::Objects::WithUtils::Hash::Immutable:

# Via List::Objects::WithUtils::Hash::Immutable ->
use List::Objects::WithUtils 'immhash';
my $hash = immhash( foo => 1, bar => 2 );
$hash->set(foo => 3);  # dies

not me writing $hash->set(foo => 3) and it straight up dies 😭 that's the point bestie, that's the whole point. the hash is locked in, main character energy, no editing arc. πŸ”₯


πŸ¦‹ DESCRIPTION πŸ¦‹

so List::Objects::WithUtils::Role::Hash::Immutable is a role, and what it does is it adds immutable behavior to consumers of List::Objects::WithUtils::Role::Hash. think of it as a glow-up where the glow-up is "you can't touch anything anymore." ✨

the following methods are not available and will throw an exception if you so much as look at them:

clear
set
maybe_set
delete
okay so real talk β€” those four? gone. not deprecated, not "handle with care," just throw an exception territory. do not come for them, they will not answer. πŸ’€

also, important: (the backing hash is also marked read-only.) so it's not just the methods, the actual hash underneath is sealed too. double locked. belt and suspenders. periodt. πŸ‘‘

and if you want to see what an actual consumer of this role looks like, go peek at List::Objects::WithUtils::Hash::Immutable. it's the demo, it's the blueprint, it's the reference implementation. 🌈


πŸ’œ AUTHOR πŸ’œ

Jon Portnoy <avenj@cobaltirc.org> β€” iconic, credited, we stan. πŸŽ€


this page came to you courtesy of perl v5.38.2, dated 2024-03-07 🧚 and yes the footer literally calls it List::...mutable(3pm) again β€” she's shy, she abbreviates. anyway ily, go read the immutable hash docs, mwah πŸ’–πŸ“

πŸ“¦ where this page comes from