Skip to content

Commit 5b0448d

Browse files
committed
Add some more info about "is dynamic"
And how it should probably not be used.
1 parent 4b50321 commit 5b0448d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

doc/Type/Variable.pod6

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,22 @@ introspect; # OUTPUT: «23␤»
6868
}
6969
=end code
7070
71+
The C<is dynamic> trait is a rather cumbersome way of creating and accessing
72+
dynamic variables. A much easier way is to use the C<* twigil>:
73+
74+
=begin code :allow<B L>
75+
sub introspect() {
76+
say B<$*x>;
77+
}
78+
my $*x = 23;
79+
introspect; # OUTPUT: «23␤»
80+
{
81+
# not dynamic
82+
my $x;
83+
introspect() # dies with an exception of L<type X::Dynamic::NotFound.new|/type/X::Dynamic::NotFound.new>
84+
}
85+
=end code
86+
7187
=head2 trait of
7288
7389
multi sub trait_mod:<of>(Mu:U $target, Mu:U $type)

0 commit comments

Comments
 (0)