in reply to Perl Moo.

Here's something to play with. I used Moo.
package Lounge::Table; use strict; use warnings; use Moo; use Sub::Quote; print "\n"; print "|The Lounge|\n"; sub table { my $self = shift; my $table_type = shift || 1; $self->wood( $self->wood - $table_type ); } has bench => ( is => 'ro', ); has type => ( is => 'ro', isa => sub { die "lounge table $!\n" unless $_[0] eq 'lounge_table' }, ); has wood => ( is => 'ro', isa => quote_sub q{ die "$_[0] isn't littered with text from computers!\n" unless "$_[0] is littered with text from computers!\n" }, ); 1; my $sit_down_at = Lounge::Table->new( bench => 'comfortable', type => 'wood', table => 'littered with text from computers', ); $sit_down_at->lounge_table; say $sit_down_at->table;

Replies are listed 'Best First'.
Re^2: Perl Moo.
by onelesd (Pilgrim) on Jul 12, 2012 at 21:24 UTC

    Can you explain what Sub::Quote does in Moo? I read the description provided from the Moo doc but I don't understand why inlining is any better than a regular coderef and I'd hate to start using it without knowing why I should be or what it does.

    SUB QUOTE AWARE "quote_sub" in Sub::Quote allows us to create coderefs that are "inlineable," giving us a handy, XS-free speed boost. Any option that is Sub::Quote aware can take advantage of this.