On 09/13/2017 04:56 PM, ToddAndMargo wrote:
Hi All,
I am trying to convert this from Perl 5:
my $WhoCalledMe = ( caller(0) )[1];
I use it inside a sub to determine who called the sub.
How is this done in P6?
Many thanks,
-T
Follow up:
With a lot of help from the chat line, it transpires that
there is no easy way to do this.
The correct method is indeed
my $WhoCalledMe = ( caller(0) )[1];
but it is not yet implemented. See bug:
https://rt.perl.org/Public/Bug/Display.html?id=123826
This was the closest I could get:
$ perl6 -e 'sub x{say "x was called by: $(callframe(1).code.name)"}; sub
y{x; say "y was called by: $(callframe(1).code.name)" }; y;'
x was called by: y
y was called by: <unit>
Poop!