Skip Menu |
Report information
Id: 117377
Status: open
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: masak <cmasak [at]>

Severity: (no value)
Tag: Bug
Platform: (no value)
Patch Status: (no value)
VM: (no value)

Subject: [BUG] 'callsame' in postcircumfix:<( )> method in routine trait does nothing in Rakudo
Date: Wed, 27 Mar 2013 16:21:53 +0100
To: rakudobug [...]
From: Carl Mäsak <cmasak [...]>
Download (untitled) / with headers
text/plain 1.3k
<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> 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 = but role { method foo { my $result = callsame; say "after $result" } }; $ <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
Download (untitled) / with headers
text/plain 798b
Hi everyone, I spent a lot of time yesterday looking at this bug, and I believe I've figured out what's going on. So Code objects do not actually have a postcircumfix:<( )> method; they rely on an 'invoke' hook in Parrot to invoke the block associated with their $!do attribute. I've tried to add the method as a fallback point for callsame and friends, but Rakudo fails to build when I do so. Hopefully someone more experienced with Rakudo will be able to take advantage of my research and fix things up! Location of invoke hook stuff: search for Code.HOW. add_parrot_vtable_mapping and Code.HOW.add_parrot_vtable_handler_mapping Attempt #1 to add postcircumfix:<( )> to Attempt #2: -Rob
Download (untitled) / with headers
text/plain 699b
This is a very old ticket and we no longer have postcircumfix:<( )> for objects. If you redo the example to use CALL-ME it still does not call the original class method, however, CALL-ME is defined as a submethod, not a method, and testing the difference: $ perl6 -e 'class S { method x { "Sx".say } }; role T { method x { "Sy".say; callsame } }; class V is S does T { }; my $v =; $v.x' Sy Sx $ perl6 -e 'class S { submethod x { "Sx".say } }; role T { method x { "Sy".say; callsame } }; class V is S does T { }; my $v =; $v.x' Sy while there may still be an "issue" if there's no way to "do that" in a modern rakudo, perhaps best to write up a new github issue and close this.

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at