Mo(3)
π Mo(3) β User Contributed Perl Documentation π
okay bestie, sit down, we're doing Micro Objects today. the manual is literally called Mo, and the whole vibe is Mo is less. π
β¨ Name β¨
Mo β Micro Objects. Mo is less. that's it. that's the whole pitch. π
π¦ Synopsis π¦
package Less;
use Mo;
extends 'Nothing';
has something => ();
see how little that is?? it's giving minimalism. it's giving main character energy with zero baggage. πβ¨
πΈ Description πΈ
use Mo. Mo is less. Much less. fr fr.
Moose is huge. Moose led to Mouse led to Moo led to Mo. M is nothing. Mo is more. Not much. π
when Moo is more than you need, drop an 'o' and get some Mo. iconic behaviour honestly. π
to get just a little Mo from Mo, use "Mo Features" below. β¬οΈ
π Core Features π
this is what you get. Nothing Mo. literally nothing extra, and we love that for us. π
π the "new" method
Mo provides a "new" object constructor. you pass it a list of name/value pairs and it returns a new object. slay. β¨
heads up bestie: the constructor will not callBUILDmethods. that's only available using theMo::buildfeature. no cap. π
π "extends"
Mo exports the "extends" keyword, to declare your parent class. "Mo::Object" itself is your default parent class. π«Ά
real talk: Mo only supports single inheritance. if you need multiple inheritance or roles, you should upgrade to Moo. periodt. π
π "has"
Mo exports a "has" keyword, to generate accessors. π
these accessors always support both "get" and "set" operations. that's it. that's the whole thing.
has name => ();
has thing => (foo => 'bar'); # arguments silently ignored
all arguments passed to "has" are ignored. and honestly? that's a feature, not a bug β it makes it easier to switch between Mo and Moo, without having to change all your accessors. π§
π "strict" and "warnings"
Mo turns on use strict and use warnings for you. she's responsible like that. π
π Embeddable
Mo is tiny. it is compressed into a single line. you can easily inline it in your code, should you want to do that. see Mo::Inline for more information, including a utility that will do it for you. π¦
β Mo Features β
Mo is the bare minimum needed for Perl OO. many times you'll want just a couple more features. don't worry. Mo's got you covered: π
use Mo qw'build default builder coerce is required';
has name1 => ( default => sub { 'Joe' } );
has name2 => ( builder => 'name_builder' );
has name3 => ( coerce => sub {$_[0]} );
has name4 => ( is => 'ro' );
has name4 => ( required => 1 );
sub BUILD {
my $self = shift;
...
}
Mo simply loads the feature classes Mo::build, Mo::default, Mo::builder, Mo::coerce, Mo::is and Mo::required. the first one supports BUILD constructing and the other three add their magics to "has". a Mo::Feature module can enhance "new", "extends" and "has", and also add new export subs, or remove existing ones. features can also be combined for a single accessor. see Mo::Features for a list of all the features and for an explanation of the Feature API.. π₯
π See π
Mo::FeaturesMo::InliningMo::HackingMo::Design
π Status π
(yeah this heading is literally empty in the original, no thoughts, head empty, we respect the silence π)
π Authors π
- Ingy dΓΆt Net
<ingy@cpan.org> - Damien 'dams' Krotkine
<dams@cpan.org> - Matt S. Trout (mst)
<mst@shadowcat.co.uk> - Christian Walde
<walde.christian@googlemail.com> - Alessandro Ranellucci (aar/alexrj)
<aar@cpan.org> - Carlos Lima (priodev)
<carlos@cpan.org>
the whole squad. the group chat. absolute legends, every single one. π«Άπ
π Copyright and License π
Copyright (c) 2011-2013. Ingy dΓΆt Net.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See http://www.perl.com/perl/misc/Artistic.html
and that's the whole page bestie π this one's fromperl v5.42.0, dated2025-07-25, and it'sMo(3)β go forth and be micro. slay. β¨π π¦
π¦ 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