At 04:04 PM 3/26/2001 -0500, James Mastros wrote:
>On Mon, Mar 26, 2001 at 03:36:08PM -0500, Dan Sugalski wrote:
> > The only issue there is whether memoization is appropriate. It could be
> > argued that it isn't (it certainly isn't with perl 5)
>Hm. I don't see a linguistic reason why it isn't with perl5. Unless the
>comparisign function as a whole is stable (IE {f(a) <=> f(b)}, the sort
>function is documented as being undefined.
>
>The only way f(a) can not be stable and f(a) <=> f(b) can be is somthing of
>a corner case. In fact, it's a lot of a corner case.
You're ignoring side-effects. The tied data may well be returned the same
every time it's accessed, but that doesn't mean that things aren't
happening behind the scenes. What if we were tracking the number of times a
scalar/hash/array was accessed? Memoizing would kill that.
Whether this is sufficient argument to not allow it is a separate issue,
but that's not my call. I'd really like it to form an optimizer standpoint,
but it does cut off the possibility for some potentially interesting things
from a programmer standpoint.
> > though I for one
> > wouldn't mind being able to more aggressively assume that data was
> > semi-constant...
>Well, you can. Unless it has magic (and more specificly, scalar get magic).
Yeah, but figuring out whether data isn't magic is rather tricky. Once a
little uncertainty comes in (Say, from AUTOLOADed subs, or from subs whose
contents we don't know at compile time because of runtime requires, or
because we really do have magic data and the potential uncertainty from it
flares out quickly) it really cuts down on what the optimizer can do.
Granted, we may just say "don't do that if you want fast code" which is OK,
but I can see the data flow analysis getting really nasty really quickly
for reasonably sized programs.
> > (Imagine returning tied data from a function loaded in via
> > do(). Imagine the optimizer. Imagine Dan's brain popping out of his head
> > and hiding behind the bookcase)
>That's a really wierd image. Twisted, even.
Just doing my part to make the world a little more surreal...
Dan
--------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
[EMAIL PROTECTED] have teddy bears and even
teddy bears get drunk