Re: RFC 228 (v1) Add memoize into the standard library
Leon Brocard [EMAIL PROTECTED] writes: Dave Storrs sent the following bits through the ether: Personally, I like the way it works at the moment; all the subs that you want to memoize are up at the top, where they are easy to see. You can add, subtract, and change the list in a few seconds, without having to hunt through your file for the actual function definition. OTOH, this seems like action at a distance to me and the most logical place would be to have it next to the memoized sub... Seconded. -- Piers
Re: RFC 228 (v1) Add memoize into the standard library
On Fri, Sep 15, 2000 at 10:21:58AM +0200, Bart Lateur wrote: On 15 Sep 2000 02:09:23 -, Perl6 RFC Librarian wrote: A version of Memoize.pm should be added into the Perl6 standard library, and it should be added as a pragmatic module (i.e. memoize.pm). Is that it? I would rather have a flag when generating the sub, er, what's that syntax again, ":something"? sub foo :memoize { ... } This RFC is a proposal to add to the standard library, not modify the language. If the language supports arbitrary subroutine attributes that can be defined in modules, then so be it. That is not the proposal I am making. This would take out the dirty work of marking a sub as memoized. Currently, the syntax is: memoize('foo'); sub foo { ... } Blech! Sez you. :-) That syntax allows memoization of builtins like gethostbyname() and cos(), both of which are quite useful when memoized. Having an explicit memoize() call also allows the user to pick and choose which of the memoize options and extentsions they want to play with, such as tied memoize caches, expiry, underlying hash implementations (if they exist in Perl6), and so forth. I would *NOT* want to see this: sub foo :lazy :currying :utf8 {encoding = big5} :memoize {cache = dns.db, cache_type = DB_FILE, expire_time = 1000, superposition = any(1..25), currying = on, encoding = big5, lazy_eval = on [...] [ more memoize options that don't belong here ] [...] } ($) { return gethostbyname($_) or gethostbyaddr($_); } Turning on those memoization options is useful. The default set of memoization features is also quite useful, and perhaps a :memoize attribute would be of value, but that's a discussion for -stdlib. (At least by my reading of the charters.) Z.
RFC 228 (v1) Add memoize into the standard library
This and other RFCs are available on the web at http://dev.perl.org/rfc/ =head1 TITLE Add memoize into the standard library =head1 VERSION Maintainer: Adam Turoff [EMAIL PROTECTED] Date: Sep 14 2000 Mailing List: [EMAIL PROTECTED] Number: 228 Version: 1 Status: Developing =head1 ABSTRACT Caching through memoization is a very useful construct. It should be a standard module. =head1 DESCRIPTION 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 Memoize.pm should be added into the Perl6 standard library, and it should be added as a pragmatic module (i.e. memoize.pm). Adding Memoize plugins (Memoize::Expire, etc.) into the standard library is a separate discussion. =head1 MIGRATION ISSUES None. =head1 IMPLEMENTATION Add memoize into the perl6 source tarball, as a pragmatic module. =head1 REFERENCES Memoize.pm http://search.cpan.org/search?dist=Memoize MiniMemoize from TPJ: http://www.plover.com/~mjd/perl/MiniMemoize/memoize.html