Re: RFC 228 (v1) Add memoize into the standard library

2000-09-18 Thread Piers Cawley

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

2000-09-15 Thread Adam Turoff

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.