develooper Front page | perl.perl6.stdlib | Postings from September 2000

RFC 228 (v2) Add memoize into the standard library

Thread Next
Perl6 RFC Librarian
September 18, 2000 23:57
RFC 228 (v2) Add memoize into the standard library
Message ID:
This and other RFCs are available on the web at

=head1 TITLE

Add memoize into the standard library

=head1 VERSION

  Maintainer: Adam Turoff <>
  Date: 14 Sep 2000
  Last Modified: 18 Sep 2000
  Mailing List:
  Number: 228
  Version: 2
  Status: Frozen


Caching through memoization is a very useful construct.  It should be a 
standard module.


Memoization is a very useful technique to transparently cache 
function return values.  It can be used to quickly optimize 
recursive functions, or functions that take a long time to
execute (such as gethostbyname).  

A version of should be added into the Perl6 standard
library, and it should be added as a pragmatic module (i.e.

Adding Memoize plugins (Memoize::Expire, etc.) into the standard library
is a separate discussion.


There were no real objections to including in the Perl6 core.


A few people mentioned that using memoize() as a function has some 
action-at-a-distance qualities, although it is useful for caching 
builtin functions such as cos() and sin().

Bart Lateur mentioned that using a sub attribute would be logical:

	sub foo :memoize {

While this does have merit, it does raise a few issues, such as being
able to turn on various Memoize extensions (such as expiry, tied
caches, etc.).  On the other hand, this syntax does have merit for
using the default set of memoize options on a sub, without any
action-at-a-distance after effects.

These problems start to deal with language issues, such as being able
to use parameterized sub attributes, and internals issues, such as
being able to find sub attributes defined and implemented in an
extension.  Neither of these are within the charter of perl6-stdlib
to figure out.




Add memoize into the perl6 source tarball, as a pragmatic module.

The Perl6 language may allow some workarounds to be avoided, such
as using a string value to specify the function to be memoized.


MiniMemoize from TPJ:

Bart Lauter's commentary on a Perl6-ish way to memoize subs:

Leon Brocard's message on removing memoize's action-at-a-distance

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About