On Wed, Mar 28, 2001 at 11:11:20AM -0500, Dan Sugalski wrote:
>    "Can perl automatically optimize away function and tie calls inside
>     a sort function, and under what circumstances?"
Agreed.

> It doesn't really matter if the functions inside the sort function are 
> idempotent--what matters is whether it's OK for us to go and memoize the 
> things (or whatever else we might choose to do)
As far as I can see, this, in essence, gives a few basic cases:
1) The sort function is ill-defined.
2) The sort function is stateless.
3) The sort function is simply internaly stateless.
4) The function is well-defined, but not stateless whatsoever.

In case 1, The sort won't work anyway, so we can ignore this case.

I'm of the opinion that we should consider 3 to be Just Plain Silly and not
worth worring about overmuch.  (These would be functions that increment a
counter every time they are accessed, for example.)

I think that the difference between 4&3 dosn't matter.  We only have things
in 4 and not 3 that vary in abs(), but not sign.

We're left with 1&2, and for 1, the sort won't work anyway.

So long as we consider 2 Just Plain Silly, we're OK memonizing.

      -=- James Mastros
-- 
The most beautiful thing we can experience is the mysterious.  It is the
source of all true art and science.  He to whom this emotion is a stranger,
who can no longer pause to wonder and stand wrapt in awe, is as good as dead.
        -=- Albert Einstein
AIM: theorbtwo       homepage: http://www.rtweb.net/theorb/

Reply via email to