Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Introducing Moops

by tobyink (Abbot)
on Aug 21, 2013 at 23:41 UTC ( #1050432=perlnews: print w/ replies, xml ) Need Help??

Moops is sugar for writing object-oriented Perl. It provides similar syntax to MooseX::Declare and Stevan Little's p5-mop-redux.

It's some glue between Moo, Type::Tiny, Function::Parameters and Try::Tiny, but for those occasions when you want the backing of a meta object protocol, allows you to easily swap Moose (or even Mouse) in place of Moo with very minimal changes.

Here's an example of a complete, usable class definition in Moops:

use Moops; class Person :ro { has first_name => (isa => Str); has last_name => (isa => Str); }

Read more at blogs.perl.org

use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name"

Comment on Introducing Moops
Download Code
Replies are listed 'Best First'.
Re: Introducing Moops
by Anonymous Monk on Aug 22, 2013 at 02:31 UTC

    but for those occasions when you want the backing of a meta object protocol,

    When is that?

      The MOP is useful when you need to perform lots of class introspection. It's therefore a requirement for a lot of class-building extensions - i.e. most of the MooseX namespace, such as MooseX::Clone, MooseX::Privacy, MooseX::MultiMethods, etc.

      That is; you probably want to use Moose if there's some MooseX module that catches your eye, or you need to delve into $class->meta; and use Moo otherwise.

      use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name"

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlnews [id://1050432]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2015-08-02 19:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...













    Results (10 votes), past polls