I am trying to understand how wrapping works in perl6. I am using this code:
First file (test.pl6):
use v6;
use lib '.';
use TestClass;
my TestClass $t .= new;
$t.wrapped(1, 7);
Second file (TestClass.pm6):
multi sub trait_mod:<is>(Routine:D \r, :$dummy!)
{
r.wrap(sub (|)
{
say 'Dummy';
callsame;
});
}
unit class TestClass;
method wrapped($a, $b) is dummy
{
say "Wrapped ($a, $b)";
}
When running test.pl6, I get:
Cannot invoke this object (REPR: Null; VMNull)
in sub at TestClass.pm6 (TestClass) line 5
in any enter at gen/moar/Metamodel.nqp line 3999
in block <unit> at test.pl6 line 7
When all the above code is in one file, it works and prints Dummy first , and then Wrapped (1, 7) .
What am I doing wrong?
Stamm source
share