On Wed, May 13, 2009 at 07:24:23AM -0700, Ovid wrote:
>
> In short, you can't:
>
> #!/usr/bin/env perl -l
>
> {
> package My::Role;
> use Moose::Role;
> use Memoize;
>
> memoize('foo');
> sub foo { __PACKAGE__ }
Looking at perldoc Memoized, it can take a subref instead, and returns
the wrapped routine, so:
__PACKAGE__->meta->add_method('foo' => memoize(sub { __PACKAGE__ }));
should work fine. So should
*foo = Sub::Name::subname 'My::Role::foo' => memoize('foo');
sub foo { __PACKAGE__ }
and so should pretty much any variant thereon.
Maybe this wants documenting somewhere in Moose for people who don't read the
Memoize docs?
--
Matt S Trout Catalyst and DBIx::Class consultancy with a clue
Technical Director and a commit bit: http://shadowcat.co.uk/catalyst/
Shadowcat Systems Limited
mst (@) shadowcat.co.uk http://shadowcat.co.uk/blog/matt-s-trout/