Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re^4: OO Perl Baby Stepsby tobyink (Canon) |
on Jun 20, 2013 at 11:46 UTC ( [id://1039960]=note: print w/replies, xml ) | Need Help?? |
Closures are totally workable as a basis for OO Perl...
However, they're slower than the more usual blessed hashref storage, because a method call will typically involve at least two sub calls. For some reason I feel compelled to produce a MooseX module allowing you to use blessed coderefs for Moose objects like the example above.
package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name
In Section
Seekers of Perl Wisdom
|
|