# New Ticket Created by  "Carl Mäsak" 
# Please include the string:  [perl #117377]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=117377 >


<hoelzro> callsame from method in a role will call the original method
from the class, won't it?
<hoelzro> I'm trying to create a routine trait for doing something
after the original routine has returned
<PerlJam> hoelzro: show us?
<hoelzro> https://gist.github.com/hoelzro/5254952

multi trait_mod:<is>(Routine:D $r, :$pre-check) {
    $r does role {
        method postcircumfix:<( )>(|) {
            say 'before';
            my $result = callsame;
            say 'after';

            say "result = $result";

            $result
        }
    }
}

sub mysub is pre-check {
    say 'there';
    17
}

mysub();

<hoelzro> so how do I do this? =)
<masak> looks compeltely right what you're doing.
<hoelzro> well, it doesn't work =(
* masak runs code locally

$ perl6 that-gist-there
before
after
result =

<masak> huh.
<hoelzro> doesn't work for you either?
<masak> r: class C { method foo { say "there"; 17 } }; my $x = C.new
but role { method foo { my $result = callsame; say "after $result" }
}; $x.foo
<p6eval> rakudo a23458: OUTPUT«there␤after 17␤»
<masak> I postulate that the trouble is with postcircumfix:<( )> somehow.
<hoelzro> I see...
<masak> it doesn't seem that 'callsame' in your code even calls the
original sub.
<hoelzro> it doesn't
<hoelzro> that's the issue =/
<hoelzro> it just skips over the line with callsame
* masak submits rakudobug

Reply via email to