Mo(3)

πŸ“¦
version 0.40 Β· 2 versions
, in fedora 43

πŸ’– 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 call BUILD methods. that's only available using the Mo::build feature. 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::Features
  • Mo::Inlining
  • Mo::Hacking
  • Mo::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 (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 from perl v5.42.0, dated 2025-07-25, and it's Mo(3) β€” go forth and be micro. slay. βœ¨πŸ’…πŸ¦‹
πŸ“¦ where this page comes from