develooper Front page | perl.perl5.porters | Postings from February 2003

Re: [PATCH] jumbo closure fix

Thread Previous | Thread Next
A Bergman
February 27, 2003 01:22
Re: [PATCH] jumbo closure fix
Message ID:

On onsdag, feb 26, 2003, at 15:49 Europe/Stockholm, Dave Mitchell wrote:

> [ requires regen_headers ]
> This patch fixes all the major outstanding closure bugs that I am aware
> of (well, apart from ones pertaining to /(?{...})/ ).
> I've achieved this by completely rewriting pad_findlex() from scratch,
> so effectively re-implementing closures from a blank sheet.

Excellent work!

> The most notable differences are.
> * named subs now close on behalf of inner subs; eg the following now
> prints 1 rather than undef:
>     {
> 	my $x = 1;
> 	sub f { sub { print $x }->() }
>     }
>     f();


> * run-time cloning is now a lot faster, eg $a = sub {$x} is 15% faster,
> $a = sub {$x+$y} is 25% faster. This is because at compile time, the 
> index
> into the parent pad is recorded for each outer lex, so cloning just
> involves grabbing each approriate value from the parent pad rather than
> calling pad_findlex() for each outer lex.

Very nice

> * There's a new global variable PL_cv_has_eval, that gets set during
> compilation if any eval-like constucts are found within the CV's ops.

Where is this stored, per CV? What is it used for.

> Will this patch break existing code? Quite possibly, although the 
> things it
> handles differently are often things that would have generated a 
> warning
> anyway.  The main problem is if there is code that tests for a 
> particular
> warning, since some of the warnings have changed. In general, dodgy
> constructs that used to silently fail, are likely to generate warnings
> now.
> I've tested this aginst my production code at work (which relies on 
> half
> of CPAN AFAIKT :-), and it didn't seem to break anything, so there's 
> hope
> yet.

We se around 60 modules of the CPAN, I will give it a shot, but I also 
think it should be applied and then we work out the potential problems.

> (If I'd known when I started work in this patch in late Decemeber, 
> that it
> would take me till the end of Feb, I might not have bothered!)

Amen that, If I had known what threading meant ... ;-)


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About