Perl 6:从函数内部获取函数名称
Perl 6: Getting the name of function from inside it
在 Perl 6 中,如何在运行时从其主体中获取 function/subroutine 的名称?
例如,
sub foo {
say "My name is: " ~ <WHAT-API-HERE??> ;
}
...
foo();
上面的代码应该打印:
My name is: foo
sub foo { say &?ROUTINE.name }
foo
显示:
foo
在 Perl 6 中,如何在运行时从其主体中获取 function/subroutine 的名称?
例如,
sub foo {
say "My name is: " ~ <WHAT-API-HERE??> ;
}
...
foo();
上面的代码应该打印:
My name is: foo
sub foo { say &?ROUTINE.name }
foo
显示:
foo