Programming with Moose/Syntax

From Wikibooks, open books for an open world
Jump to navigation Jump to search

A big problem with the CPAN docs thus far is they utilize (abuse) the fact that Moose is an application of Class::MOP. Class::MOP is Meta Object Protocol building framework - and that is usually about where the cryptic confusion sets in.. There is a very blurry distinction between Class::MOP and Moose, because Moose is the only known application of Class::MOP.

Essentially what we have in Class::MOP is an archive of hacks that allow Moose to be terse and non-perlish. Moose makes a few of these hacks available with out much sugar but generally speaking candy coats them to a comfortable level.

In this syntax compendium of Moose we promise to never mention Class::MOP again.[1]

Table of Contents[edit | edit source]

Wikibook Development Stages
Sparse text 0% Developing text 25% Maturing text 50% Developed text 75% Comprehensive text 100%

Keywords exported with use Moose;:

  1. has 75% developed
  2. before, after, around 75% developed
  3. blessed
  4. override 0% developed
  5. augment
  6. extends 75% developed
  7. with
  8. meta
  9. Other functions - Non-polluting fully-qualified syntax 25% developed

Use of 'no Moose'[edit | edit source]

15:32 <@konobi> less shit to track during runtime
15:33 <@Sartak> EvanCarroll: my $person = Person->new; $person->has("jewelry")
15:33 <@konobi> just _having_ stuff in your namespace will slow the interpreter down
15:33 <@Sartak> if you keep Moose's functions in Person's namespace, that will have weird results
15:33 <@Sartak> if you no Moose, then it's the usual "undefined function" error

Footnotes[edit | edit source]

^ Class::MOP, last time, I swear.