Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Perl Moo.

by Khen1950fx (Canon)
on Jun 13, 2012 at 16:59 UTC ( [id://976018]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-20 00:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found