X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;ds=inline;f=lib%2FScope%2FUpper.pm;h=0fa353431ea0fe5df5821aa1dd6d29a891669c33;hb=6c74fb492a0404fa8822211cba07b1027ce3cfec;hp=1ae9f9c7f117c9b6948e8ff61c79abeda2eff4c3;hpb=b143b5ed4d9b116054d12ea0696167b6a199b500;p=perl%2Fmodules%2FScope-Upper.git
diff --git a/lib/Scope/Upper.pm b/lib/Scope/Upper.pm
index 1ae9f9c..0fa3534 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.19
+Version 0.21
=cut
our $VERSION;
BEGIN {
- $VERSION = '0.19';
+ $VERSION = '0.21';
}
=head1 SYNOPSIS
@@ -170,7 +170,11 @@ localize variables, array/hash values or deletions of elements in higher context
=item *
-return values immediately to an upper level with L, and know which context was in use then with L ;
+return values immediately to an upper level with L, L and L ;
+
+=item *
+
+gather information about an upper context with L and L ;
=item *
@@ -270,7 +274,10 @@ C<$key> is either an array index or a hash key, depending of which kind of varia
If C<$what> is a string pointing to an undeclared variable, the variable will be vivified as soon as the localization occurs and emptied when it ends, although it will still exist in its glob.
-=head2 C
+=head2 C
+
+ localize_delete $what, $key;
+ localize_delete $what, $key, $context;
Introduces the deletion of a variable or an array/hash element delayed to the time of first return into the upper scope denoted by C<$context>.
C<$what> can be:
@@ -295,10 +302,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 restarts 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
@@ -312,14 +320,49 @@ This means that
will set C<$num> to C<'z'>.
You can use L to handle these cases.
+=head2 C
+
+ yield;
+ yield @values, $context;
+
+Returns C<@values> I the context pointed by or just above C<$context>, and immediately restarts the program flow at this point.
+If C<@values> is empty, then the C<$context> parameter is optional and defaults to the current context ; otherwise it is mandatory.
+
+L differs from L in that it can target I upper scope (besides a C substitution context) and not necessarily a sub, an eval or a format.
+Hence you can use it to return values from a C or a C act depending on t
# $cxt = SCOPE(4), UP SUB UP SUB = UP SUB EVAL = UP CALLER(2) = TOP
...
-Where L, L and L point to depending on the C<$cxt>:
+Where L, L, L, L and L point to depending on the C<$cxt>:
sub {
eval {
sub {
{
- unwind @things => $cxt; # or uplevel { ... } $cxt;
+ unwind @things => $cxt; # or yield @things => $cxt
+ # or uplevel { ... } $cxt
...
}
...
@@ -608,7 +712,7 @@ Where L, L and L point to depending on the C<$cxt>:
=head1 EXPORT
-The functions L, L, L, L, L, L and L are only exported on request, either individually or by the tags C<':funcs'> and C<':all'>.
+The functions L, L, L, L, L, L, L, L, L and L are only exported on request, either individually or by the tags C<':funcs'> and C<':all'>.
The constant L is also only exported on request, individually or by the tags C<':consts'> and C<':all'>.
@@ -623,7 +727,8 @@ our %EXPORT_TAGS = (
funcs => [ qw<
reap
localize localize_elem localize_delete
- unwind want_at
+ unwind yield leave
+ want_at context_info
uplevel
uid validate_uid
> ],
@@ -687,7 +792,12 @@ Despite this shortcoming, this XS version of L should still run way fa
=head1 DEPENDENCIES
-L (standard since perl 5.006).
+L 5.6.
+
+A C compiler.
+This module may happen to build with a C++ compiler as well, but don't rely on it, as no guarantee is made in this regard.
+
+L (core since perl 5.006).
=head1 SEE ALSO