On Fri, Sep 15, 2000 at 10:21:58AM +0200, Bart Lateur wrote:
> On 15 Sep 2000 02:09:23 -0000, 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.

Reply via email to