Class:...:Lvalue(3pm)

πŸ“¦
version 0.11 Β· 2 versions
  • 0.11 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.11 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Class::Accessor::Lvalue β€” the perl manual, but make it cute ✨

okay so bestie, this is Class:...:Lvalue(3pm) from the User Contributed Perl Documentation, and yes the module's actual name is Class::Accessor::Lvalue πŸ’… (the header's just being dramatic with the abbreviation). We're gonna get you lvalue accessors and you're gonna thrive.


✨ NAME ✨

Class::Accessor::Lvalue β€” create Lvalue accessors πŸŽ€


🌸 SYNOPSIS 🌸

package Foo;
use base qw( Class::Accessor::Lvalue );
__PACKAGE__->mk_accessors(qw( bar ))

my $foo = Foo->new;
$foo->bar = 42;
print $foo->bar; # prints 42

like… you literally just assign to it. no ->bar(42) nonsense. it's giving direct assignment. it's giving main character energy. πŸ¦‹


πŸ’œ DESCRIPTION πŸ’œ

This module subclasses Class::Accessor so it can hand you lvalue accessor makers. That's the whole vibe. It takes what Class::Accessor already does and makes the accessors assignable, no cap. ✨


😭 CAVEATS 😭

bestie listen, read this part, it's important:

  • Though Class::Accessor mutators allow for the setting of multiple values to an attribute, the mutators that this module creates handle single scalar values only. Not the end of the world though β€” this should not be too much of a hinderance, because you can still explicitly use an anonymous array. πŸ™ˆ
  • Due to the hoops we have to jump through to preserve the Class::Accessor ->get and ->set behaviour, this module is potentially slow. 🐌
If you don't actually need the flexibility that the ->get and ->set methods grant you, it's highly reccomended that you use Class::Accessor::Lvalue::Fast instead β€” it's simpler and much faster. fr fr, go look at it. πŸ”₯

πŸ‘‘ AUTHOR πŸ‘‘

Richard Clamp <richardc@unixbeard.net> β€” with many thanks to Yuval Kogman for helping with the groovy lvalue tie magic used in the main class. 🧚 the tie magic is genuinely iconic, we owe Yuval one.


Copyright (C) 2003 Richard Clamp. All Rights Reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. πŸ’–


⭐ SEE ALSO ⭐

  • Class::Accessor
  • Class::Accessor::Lvalue::Fast

and that's the whole page, bestie 🫢 this one's from perl v5.34.0, dated 2022-06-10, filed under Class:...:Lvalue(3pm) in the User Contributed Perl Documentation. go forth and assign directly, you absolute legend πŸ’…βœ¨

πŸ“¦ where this page comes from