From: Vincent Pit Date: Thu, 13 Sep 2012 17:33:07 +0000 (+0200) Subject: Fix the documentation of the context argument of unwind() and uplevel() X-Git-Tag: v0.20~10 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FScope-Upper.git;a=commitdiff_plain;h=ca50ad37afae0c65ddc432c03f68d5cefae4de29 Fix the documentation of the context argument of unwind() and uplevel() --- diff --git a/lib/Scope/Upper.pm b/lib/Scope/Upper.pm index 2ca1a2d..f4d43e7 100644 --- a/lib/Scope/Upper.pm +++ b/lib/Scope/Upper.pm @@ -298,10 +298,11 @@ C<$key> is ignored. =head2 C - unwind @values; + unwind; unwind @values, $context; -Returns C<@values> I the context pointed by C<$context>, i.e. from the subroutine, eval or format at or just above C<$context>, and immediately restart the program flow at this point - thus effectively returning to an upper scope. +Returns C<@values> I the subroutine, eval or format context pointed by or just above C<$context>, and immediately restart the program flow at this point - thus effectively returning C<@values> to an upper scope. +If C<@values> is empty, then the C<$context> parameter is optional and defaults to the current context (making the call equivalent to a bare C) ; otherwise it is mandatory. The upper context isn't coerced onto C<@values>, which is hence always evaluated in list context. This means that @@ -335,8 +336,7 @@ will rightfully set C<$num> to C<26>. =head2 C my @ret = uplevel { ...; return @ret }; - my @ret = uplevel { my @args = @_; ...; return @ret } @args; - my @ret = uplevel { ... } @args, $context; + my @ret = uplevel { my @args = @_; ...; return @ret } @args, $context; my @ret = &uplevel($callback, @args, $context); Executes the code reference C<$callback> with arguments C<@args> as if it were located at the subroutine stack frame pointed by C<$context>, effectively fooling C and C into believing that the call actually happened higher in the stack. @@ -355,6 +355,8 @@ The code is executed in the context of the C call, and what it returns my @inverses = target(1, 2, 4); # @inverses contains (0, 0.5, 0.25) my $count = target(1, 2, 4); # $count is 3 +Note that if C<@args> is empty, then the C<$context> parameter is optional and defaults to the current context ; otherwise it is mandatory. + L also implements a pure-Perl version of C. Both are identical, with the following caveats :