is dynamic
ErrorsCollection

is dynamic

Synthesised documentation from type/Variable

From type/Variable

See Original text in context

multi sub trait_mod:<is>(Variable:D:$dynamic)

Marks a variable as dynamic, that is, accessible from inner dynamic scopes without being in an inner lexical scope.

sub introspect() {
    say <strong>$CALLER::x</strong>;
}
my $x <strong>is dynamic</strong> = 23;
introspect;         # OUTPUT: «23␤» 
{
    # not dynamic 
    my $x;
    introspect()    # dies with an exception of <a href="/type/X/Caller/NotDynamic.html">type X::Caller::NotDynamic</a> 
}

The is dynamic trait is a rather cumbersome way of creating and accessing dynamic variables. A much easier way is to use the * twigil:

sub introspect() {
    say <strong>$*x</strong>;
}
my $*x = 23;
introspect;         # OUTPUT: «23␤» 
{
    # not dynamic 
    my $x;
    introspect()    # dies with an exception of <a href="/type/X/Dynamic/NotFound.html">type X::Dynamic::NotFound</a> 
}