List::...mutable(3pm)
π 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
- debian trixie: liblist-objects-withutils-perl 2.028003-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: liblist-objects-withutils-perl 2.028003-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: liblist-objects-withutils-perl 2.028003-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms