Skip to content

Commit 656b336

Browse files
committed
Document dynamic-scope pragma
1 parent 44e67a1 commit 656b336

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

doc/Language/pragmas.pod6

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,35 @@ pragmas, currently the three above; thus, it would be equivalent to
7474
use MONKEY-SEE-NO-EVAL;
7575
use MONKEY-GUTS;
7676
77+
X<dynamic-scope, pragma>
78+
=head2 dynamic-scope
79+
80+
Applies the L<is dynamic|/type/Variable#trait_is_dynamic> trait to variables
81+
in the pragma's lexical scope. The effect can be restricted to a subset of
82+
variables by listing their names as arguments. By default applies to I<all>
83+
variables.
84+
85+
=begin code :allow<C>
86+
# Apply C<is dynamic> only to $x, but not to $y
87+
use dynamic-scope <$x>;
88+
89+
sub poke {
90+
say $CALLER::x;
91+
say $CALLER::y;
92+
}
93+
94+
my $x = 23;
95+
my $y = 34;
96+
poke;
97+
98+
# OUTPUT:
99+
# 23
100+
# Cannot access '$y' through CALLER, because it is not declared as dynamic
101+
=end code
102+
103+
This pragma is not currently part of any Perl 6 specification and was added
104+
in Rakudo 2019.03.
105+
77106
X<|experimental, pragma>
78107
=head2 experimental
79108

0 commit comments

Comments
 (0)