Rakudo-specific class that wraps around code in other languages (generally NQP)
does Callable
ForeignCode
is a Raku wrapper around code that is not written originally in that language; its intention is to use these blocks of code in Callable
contexts easily. For instance, subs have some anonymous functions that are actually ForeignCode
.
sub does-nothing();say .name ~ ' → ' ~ .^name for .^methods;# OUTPUT: «<anon> → ForeignCode<anon> → ForeignCodesoft → Method…»
This script will map method names to their class, and it shows that routines, in particular, have several methods that are actually ForeignCode
instead of Method
s.
method arity()
Returns the arity of the enclosed code.
method count()
Returns the number of arguments the enclosed code needs.
method signature( ForeignCode: )
Returns the signature of the enclosed code.
method name()
Returns the name of the enclosed code, or <anon>
if it has not received any.
method gist( ForeignCode: )
Returns the name of the code by calling name
.
method Str( ForeignCode: )
Returns the name of the code by calling name
.