On Sun, Dec 05, 2004 at 09:54:36PM -0800, Brian Ingerson wrote:
> Please do fix any bugs, but please also leave me an out.
First off, aplologies for not concentrating more time on this, but in the
last week I've been doing sound for a local theatre group, *and* I've had
a cold, so I've been a bit busy!
> Is it possible to save the original args if something like
> $DB::please_save_original_args is set? That would work for me.
Quite possibly, but I want to think long and hard about this issue first.
Note that the semantics of @DB::args is (and always has been):
"the current value of the parent @_ (not the *original* @_), plus
possibly some of the earlier elements of @_ if they happened to have
been shifted earlier, and assuming they haven't been freed in the
meantime, or even been reallocated to something else; and whether they
have been freed is implementation dependent and varies from release to
release (and happens to have changed betwwen 5.8.5 and 5.8.6)"
Unfortunately it's never been documented like that, so people have been
making use of it :-(
> It seems the functionality you are giving up for this fix is just
> too valuable. I'm sure it's valuable to more than just Spiffy.pm
> and SUPER.pm.
Note that the fix in 5.8.6 is *not* giving up functionality; it is just
excercising @DB::args design flaws in different ways. It's quite possible
to break Spiffy on earlier perls, eg this breaks on 5.8.0 and 5.8.5:
package A;
use Spiffy '-Base';
sub a { print "ok 1\n" };
package B;
use base 'A';
sub a {
push @_, '1'; # XXX this breaks it
super;
}
package main;
B->new->a;
> Also since I already am hanging, with the current release, I need
> something to keep Spiffy limping along. I'm planning on releasing this
> rather unsatisfying patch:
I'd suggest the following fix instead: you lose the tail recursion
optimisation, but I don't think that's a huge loss:
--- lib/Spiffy.pm- Mon Dec 6 20:40:53 2004
+++ lib/Spiffy.pm Mon Dec 6 20:48:09 2004
@@ -290,7 +290,7 @@
if (defined &{"${super_class}::$method"}) {
${"$super_class\::AUTOLOAD"} = ${"$class\::AUTOLOAD"}
if $method eq 'AUTOLOAD';
- goto &{"${super_class}::$method"};
+ return &{"${super_class}::$method"}(@_);
}
}
return;
--
"You're so sadly neglected, and often ignored.
A poor second to Belgium, When going abroad."
-- Monty Python - "Finland"