Moose quick-ref card

brian_d_foy on 2007-11-04T23:55:00

I recently had a few spare tuits and ran out of books to read, so the Moose object system popped to the top of my stack.

Like many new and cool projects, features are accellerating away from documentation, and often what a new starter wants is a low-down, which isn't there (yet). Catalyst and DBIx::Class were each like this at one point in time.

To help myself and others I have created a PDF Moose Quick-Ref Card with most of the functions and syntactic sugar consructs of the system.

Thanks go to folks in the #moose IRC channel, and the Programming With Moose WikiBook written by EvanCarroll. The ref card will work best if you can print it 2-up on one A4 sheet, cut that in half, then laminate the two A5 parts back-to-back.

Comments and suggestions for the ref-card will be gratefully received :-)


Additions..

groditi on 2007-11-05T01:04:30

"use Moose;" also automatically "use"s strict and warnings.

The next release of Moose / MOP should have the new builder / lazy_build attribute options (ask in IRC about it if you want to know more)

meta->make_immutable / meta->make_mutable: allow you to "lock" a class down. By telling Class::MOP that you will not make any further changes to the class (you can still extend via inheritance), we gain the ability to memoize / inline some internals, improving performance.

Re:Additions..

perigrin on 2007-11-05T01:45:43

meta->makeimmutable / meta->makemutable: allow you to “lock” a class down. By telling Class::MOP that you will not make any further changes to the class (you can still extend via inheritance), we gain the ability to memoize / inline some internals, improving performance.

This is not to be under sold. I was randomly doing benchmarks against a class builder that shall remain namelessly … immutable made us perform within the realm of consideration considering what Moose provides.

* Moose::Tiny will probably feature these benchmarks in the next version.

Predicate behavior

groditi on 2007-11-07T19:42:34

IN your quickref card you describe as basic checks for defined ness. This was a bug and is now fixed, predicates act more like exists now in that $class->attr(undef); Will make the attribute's predicate return true. Please see groditi in IRC if you have any questions.

Corrected behavior:
Predicates return true if value was deliberately set to undef
Attributes return false only when the attribute was never set.
Readers of unset attributes will return undef without autovivify ing the value