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.
Scope::Upper - Act on upper scopes.
VERSION
- Version 0.16
+ Version 0.17
SYNOPSIS
"reap", "localize", "localize_elem", "localize_delete" and "WORDS" :
* 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
}
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
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
...
# (*) 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",
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).
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
Scope::Escape.
- Sub::Uplevel provides a pure-Perl implementation of "uplevel".
-
AUTHOR
Vincent Pit, "<perl at profvince.com>", <http://www.profvince.com>.