Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re^3: Making lexically-scoped ref available to non-OO subs in another packageby tobyink (Canon) |
on Jul 13, 2013 at 07:35 UTC ( [id://1044128]=note: print w/replies, xml ) | Need Help?? |
I probably wouldn't have come up with it so quickly if I hadn't been playing around with p5-mop-redux which is a prototype of a hopefully future Perl core feature. The prototype uses rather a similar technique (combined with lots of Devel::Declare magic) to provide its class-building syntax, though it uses localized package variables rather than lexicals. (I've also done something fairly similar in Smart::Dispatch.)
package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name
In Section
Seekers of Perl Wisdom
|
|