[vienna.pm] [ANNOUNCE] Attribute::Memoize 0.01
Marcel Grunauer
marcel at codewerk.com
Fri May 18 15:27:28 CDT 2001
* * * vienna-pm-list * * *
NAME
Attribute::Memoize - Attribute interface to Memoize.pm
SYNOPSIS
use Attribute::Memoize;
sub fib :Memoize {
my $n = shift;
return $n if $n < 2;
fib($n-1) + fib($n-2);
}
$|++;
print fib($_),"\n" for 1..50;
DESCRIPTION
This module makes it slightly easier (and modern) to memoize a function
by providing an attribute, `:Memoize' that makes it unnecessary for you
to explicitly call `Memoize::memoize()'. Options can be passed via the
attribute per usual (see the `Attribute::Handlers' manpage for details,
and the `Memoize' manpage for information on memoizing options):
sub f :Memoize(NORMALIZER => 'main::normalize_f') {
...
}
However, since the call to `memoize()' is now done in a different
package, it is necessary to include the package name in any function
names passed as options to the attribute, as shown above.
TODO
test.pl
BUGS
None known so far. If you find any bugs or oddities, please do inform
the author.
AUTHOR
Marcel GrĂ¼nauer, <marcel at codewerk.com>
COPYRIGHT
Copyright 2001 Marcel GrĂ¼nauer. All rights reserved.
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
SEE ALSO
perl(1), Attribute::Handlers(3pm).
Marcel
--
We are Perl. Your table will be assimilated. Your waiter will adapt to
service us. Surrender your beer. Resistance is futile.
-- London.pm strategy aka "embrace and extend" aka "mark and sweep"
###
You are subscribed to vienna-pm-list as Marcel Grunauer <marcel at codewerk.com>
http://www.fff.at/fff/vienna.pm/
More information about the Vienna-pm
mailing list