develooper Front page | perl.perl6.language | Postings from November 2002

Re: Superpositions and laziness

From:
Piers Cawley
Date:
November 8, 2002 14:26
Subject:
Re: Superpositions and laziness
Message ID:
84adkjhf7c.fsf@despairon.bofh.org.uk
Paul Johnson <paul@pjcj.net> writes:

> On Fri, Nov 08, 2002 at 12:12:53PM -0700, Luke Palmer wrote:
>
>> What's wrong with C<cached>?
>> 
>> C<pure> ain't bad either, but it won't appeal to
>> non-mathematicians---even certain kinds of mathematicians.
>> Mathematica thinks a "pure" function is what we think of as an
>> "anonymous" sub.  So I like C<cached>.
>
> Part of the reason I would prefer something like "pure" over something
> like "cached" is because it describes the function rather than telling
> the compiler how to deal with it.  That feels better to me.  It's
> working at a higher level.  Maybe the end result is the same, or maybe
> there are other optimisations which can be made with "pure" functions.
> It's a way of nailing down the contract on the function rather than
> specifying implementation details.

This man is right. Listen to him. After all, if functions get labelled
as 'pure' one could potentially write:

    package MemoizePureFuncs {
      sub import($package) {
        for $package.functions -> $func {
          Memoize::memoize($func) if $func.attribs{pure};
        }
      }
    }

Or any other optimization you think is worth applying to all pure
functions.

-- 
Piers

   "It is a truth universally acknowledged that a language in
    possession of a rich syntax must be in need of a rewrite."
         -- Jane Austen?



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About