Mo::builder(3)
Mo::builder π
okay so bestie, welcome to the Perl manual page for Mo::builder (that's section 3 of the manual, for all you library-functions girlies out there) π
β¨ Name β¨
Mo::builder</purpose> β it adds the builder feature to Mo's has. that's it. that's the whole job. and she does it flawlessly. π¦
β¨ Synopsis β¨
here's the vibe, copy-paste girlies:
use Mo qw'builder';
has name => ( builder => 'name_lookup' );
sub name_lookup {
my ($self) = @_;
...
}
likeβ¦ look at her. immaculate. no notes. π
β¨ Description β¨
so what's actually happening here? Mo::builder adds the builder parameter to has, and that parameter expects a method name. that method gets executed on $self to set the attribute β but only if it hasn't been set yet. it's giving "don't do the work twice, we're not doing that here" energy. periodt. π
β¨ Laziness β¨
ngl the name of this section is sending me, but it's actually about something real: builders in Mo are lazy by default. πΈ
you can change that tho β just explicitly set the lazy argument to false, and then it gets initialized during instantiation instead. main character behavior, honestly:
use Mo qw'builder';
has status => ( builder => '_build_status' ); # lazy
has source => ( builder => '_build_source', lazy => 1); # lazy
has target => ( builder => '_build_target', lazy => 0); # eager
see how lazy => 1 keeps it lazy and lazy => 0 makes it eager? iconic. no cap. β¨
and if you wanna flip the whole default β make builders eager by default instead β just import nonlazy:
use Mo qw'builder nonlazy';
has status => ( builder => '_build_status' ); # eager
has source => ( builder => '_build_source', lazy => 1); # lazy
has target => ( builder => '_build_target', lazy => 0); # eager
look at that. flipped the script. the lazy => 1 still holds it down as lazy, lazy => 0 is eager, and the no-arg one defaults to eager now because you said nonlazy. we love a configurable queen. ππ
heads up bestie: default is lazy. if you want eager without saying it every single time, nonlazy is your girl. π«Ά
and that's the whole page, fr fr. this lil masterpiece is from perl v5.42.0, dated 2025-07-25, and it lives at Mo::builder(3) in the User Contributed Perl Documentation. mwah. go build something cute. ππ§β
π¦ where this page comes from
- fedora 43: perl-Mo 0.40-28.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms