Documentation for method raw assembled from the following pages:

Class: Parameter §

From Parameter

(Parameter) method raw §

Defined as:

method raw(Parameter:D: --> Bool:D)

Returns True for raw parameters.

sub f($a$b is raw, \c{
    my $sig = &?ROUTINE.signature;
    for ^$sig.params.elems {
        say $sig.params[$_].raw;
    }
}
f(17"4711"42); # OUTPUT: «False␤True␤True␤»

Raw parameters bind either a variable or a value passed to it, with no decontainerization taking place. That means that if a variable was passed to it, you can assign to the parameter. This is different from rw-parameter which can only bind to variables, never to values.

This is the normal behavior for parameters declared with a sigil of '\', which is not really a sigil insofar as it is only used on the parameter.

sub f(\x{
    x = 5;
}
f(my $x);   # works 
f(42);      # dies 
CATCH { default { put .^name''.Str } };
# OUTPUT: «X::Assignment::RO: Cannot modify an immutable Int␤»

Other parameters may become raw through use of the 'is raw' trait. These still use their sigil in code.

sub f($x is raw{
    $x = 5;
}

When used with slurpy list parameters, the is raw trait will cause the list of arguments given to be packed into a List instead of an Array, which prevents them from being containerized with Scalar. This is the default behavior when using + with a sigilless parameter:

my @types is List = MuAny;
say -> *@l { @l }(@types)[0=:= @types[0];        # OUTPUT: «False␤» 
say -> +@l { @l }(@types)[0=:= @types[0];        # OUTPUT: «False␤» 
say -> +l { l }(@types)[0=:= @types[0];          # OUTPUT: «True␤» 
say -> *@l is raw { @l }(@types)[0=:= @types[0]; # OUTPUT: «True␤»