From: Vincent Pit Date: Mon, 3 Oct 2011 21:46:51 +0000 (+0200) Subject: This is 0.17 X-Git-Tag: v0.17^0 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FScope-Upper.git;a=commitdiff_plain;h=cb2377339e35cfbadcaf35f75434972bbaf741bc This is 0.17 --- diff --git a/Changes b/Changes index 5fd9db0..43cec7e 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,33 @@ Revision history for Scope-Upper +0.17 2011-10-03 21:45 UTC + + Fix : uplevel() will now use the correct pad when executing its callback. This fixes at least two issues : + - closures defined inside the uplevel callback can now correctly + access lexicals from inside and outside the callback. + - state variables in the uplevel callback now work properly. + + Fix : It is now generally possible to call goto() in the uplevel'd + code to replace the uplevel stack frame. There are two cases + for which it is still not possible : + - if -D flags were set when running perl (as in "perl -Dt ..."). + - if the perl runloop has been replaced with a custom one by + another module. + If uplevel() detects that the replacement code contains a goto + statement, and is in one of those two cases, then it will refuse + to execute the callback and throw an exception. + Note that this fix implies a run-time overhead of uplevel() + proportional to the size of the the callback in every case + (with a small ratio), and proportional to the size of ALL the + code executed as the result of the uplevel call (including + subroutine calls inside the callback) when a goto statement is + found in the uplevel callback. + + Fix : uplevel() has been taught how to handle XS callbacks properly. + + Fix : The cause of "Attempt to free unreferenced scalar" warnings + when using uplevel() has been addressed. + + Fix : [RT #71212] : build failure on Windows. + The module does no longer rely on calling Perl_cv_clone, which + isn't exported. + Thanks C.H. Kang for reporting. + 0.16 2011-09-03 23:00 UTC + Add : uplevel($code, @args, $cxt) executes $code with arguments @args in the upper context pointed by $cxt. diff --git a/META.json b/META.json index 8c9b300..746f43c 100644 --- a/META.json +++ b/META.json @@ -4,7 +4,7 @@ "Vincent Pit " ], "dynamic_config" : 1, - "generated_by" : "ExtUtils::MakeMaker version 6.59, CPAN::Meta::Converter version 2.112150", + "generated_by" : "ExtUtils::MakeMaker version 6.59, CPAN::Meta::Converter version 2.112621", "license" : [ "perl_5" ], @@ -57,5 +57,5 @@ "url" : "http://git.profvince.com/?p=perl%2Fmodules%2FScope-Upper.git" } }, - "version" : "0.16" + "version" : "0.17" } diff --git a/META.yml b/META.yml index ee2d607..36c1da1 100644 --- a/META.yml +++ b/META.yml @@ -12,7 +12,7 @@ configure_requires: Config: 0 ExtUtils::MakeMaker: 0 dynamic_config: 1 -generated_by: 'ExtUtils::MakeMaker version 6.59, CPAN::Meta::Converter version 2.112150' +generated_by: 'ExtUtils::MakeMaker version 6.59, CPAN::Meta::Converter version 2.112621' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html @@ -32,4 +32,4 @@ resources: homepage: http://search.cpan.org/dist/Scope-Upper/ license: http://dev.perl.org/licenses/ repository: http://git.profvince.com/?p=perl%2Fmodules%2FScope-Upper.git -version: 0.16 +version: 0.17 diff --git a/README b/README index 3a5d767..faa4a76 100644 --- a/README +++ b/README @@ -2,7 +2,7 @@ NAME Scope::Upper - Act on upper scopes. VERSION - Version 0.16 + Version 0.17 SYNOPSIS "reap", "localize", "localize_elem", "localize_delete" and "WORDS" : @@ -126,7 +126,7 @@ DESCRIPTION * return values immediately to an upper level with "unwind", and know which context was in use then with "want_at" ; - * execute a subroutine in the context of an upper subroutine stack + * execute a subroutine in the setting of an upper subroutine stack frame with "uplevel". FUNCTIONS @@ -274,15 +274,15 @@ FUNCTIONS } my @inverses = target(1, 2, 4); # @inverses contains (0, 0.5, 0.25) - my $count = target(1, 2, 4); # $target is 3 + my $count = target(1, 2, 4); # $count is 3 Sub::Uplevel also implements a pure-Perl version of "uplevel". Both are identical, with the following caveats : * The Sub::Uplevel implementation of "uplevel" may execute a code reference in the context of any upper stack frame. The Scope::Upper - version only allows to uplevel to a subroutine stack frame, and will - croak if you try to target an "eval" or a format. + version can only uplevel to a subroutine stack frame, and will croak + if you try to target an "eval" or a format. * Exceptions thrown from the code called by this version of "uplevel" will not be caught by "eval" blocks between the target frame and the @@ -307,7 +307,7 @@ FUNCTIONS will print "inner block: wut..." with Sub::Uplevel and "outer block: wut..." with Scope::Upper. - * Sub::Uplevel globally overrides "CORE::GLOBAL::caller", while + * Sub::Uplevel globally overrides the Perl keyword "caller", while Scope::Upper does not. A simple wrapper lets you mimic the interface of "uplevel" in @@ -425,7 +425,7 @@ WORDS ... # (*) Note that uplevel() will croak if you pass that scope frame, - # because it can't target eval scopes. + # because it cannot target eval scopes. EXPORT The functions "reap", "localize", "localize_elem", "localize_delete", @@ -472,6 +472,21 @@ CAVEATS may help to use a perl higher than 5.8.9 or 5.10.0, as they contain some context-related fixes. + Calling "goto" to replace an "uplevel"'d code frame does not work when a + custom runloop is used or when debugging flags are set with "perl -D". + In those two cases, "uplevel" will look for a "goto &sub" statement in + its callback and, if there is one, throw an exception before executing + the code. + + Moreover, in order to handle "goto" statements properly, "uplevel" + currently has to suffer a run-time overhead proportional to the size of + the the callback in every case (with a small ratio), and proportional to + the size of all the code executed as the result of the "uplevel" call + (including subroutine calls inside the callback) when a "goto" statement + is found in the "uplevel" callback. Despite this shortcoming, this XS + version of "uplevel" should still run way faster than the pure-Perl + version from Sub::Uplevel. + DEPENDENCIES XSLoader (standard since perl 5.006). @@ -480,6 +495,8 @@ SEE ALSO Alias, Hook::Scope, Scope::Guard, Guard. + Sub::Uplevel. + Continuation::Escape is a thin wrapper around Scope::Upper that gives you a continuation passing style interface to "unwind". It's easier to use, but it requires you to have control over the scope where you want @@ -487,8 +504,6 @@ SEE ALSO Scope::Escape. - Sub::Uplevel provides a pure-Perl implementation of "uplevel". - AUTHOR Vincent Pit, "", . diff --git a/lib/Scope/Upper.pm b/lib/Scope/Upper.pm index eefe253..377e434 100644 --- a/lib/Scope/Upper.pm +++ b/lib/Scope/Upper.pm @@ -9,13 +9,13 @@ Scope::Upper - Act on upper scopes. =head1 VERSION -Version 0.16 +Version 0.17 =cut our $VERSION; BEGIN { - $VERSION = '0.16'; + $VERSION = '0.17'; } =head1 SYNOPSIS