Skip to content

Commit

Permalink
Document dynamic-scope pragma
Browse files Browse the repository at this point in the history
  • Loading branch information
taboege committed May 20, 2019
1 parent 44e67a1 commit 656b336
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions doc/Language/pragmas.pod6
Expand Up @@ -74,6 +74,35 @@ pragmas, currently the three above; thus, it would be equivalent to
use MONKEY-SEE-NO-EVAL;
use MONKEY-GUTS;
X<dynamic-scope, pragma>
=head2 dynamic-scope
Applies the L<is dynamic|/type/Variable#trait_is_dynamic> trait to variables
in the pragma's lexical scope. The effect can be restricted to a subset of
variables by listing their names as arguments. By default applies to I<all>
variables.
=begin code :allow<C>
# Apply C<is dynamic> only to $x, but not to $y
use dynamic-scope <$x>;
sub poke {
say $CALLER::x;
say $CALLER::y;
}
my $x = 23;
my $y = 34;
poke;
# OUTPUT:
# 23
# Cannot access '$y' through CALLER, because it is not declared as dynamic
=end code
This pragma is not currently part of any Perl 6 specification and was added
in Rakudo 2019.03.
X<|experimental, pragma>
=head2 experimental
Expand Down

0 comments on commit 656b336

Please sign in to comment.