Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
69 lines (39 sloc) 1.65 KB
=begin pod
=TITLE class ForeignCode
=SUBTITLE Rakudo-specific class that wraps around code in other languages (generally NQP)
class ForeignCode does Callable {}
N<This is a Rakudo specific class, and as such it is advisable not to use it in
your own code, since its interface might change or even disappear in the future.
This is provided here only as a reference>
C<ForeignCode> is a Perl 6 wrapper around code that is not written originally in
that language; its intention is to use these blocks of code in C<Callable>
contexts easily. For instance, subs have some anonymous functions that are
actually C<ForeignCode>.
=for code
sub does-nothing(){};
say $ ~ ' → ' ~ $_.^name for &does-nothing.^methods;
# OUTPUT: «<anon> → ForeignCode␤<anon> → ForeignCode␤soft → Method␤…»
This script will map method names to their class, and it shows that routines, in
particular, have several methods that are actually C<ForeignCode> instead of
=head1 Methods
=head2 method arity
method arity()
Returns the arity of the enclosed code.
=head2 method count
method count()
Returns the number of arguments the enclosed code needs.
=head2 method signature
method signature( ForeignCode:D: )
Returns the signature of the enclosed code.
=head2 method name
method name()
Returns the name of the enclosed code, or C«<anon>» if it has not received any.
=head2 method gist
method gist( ForeignCode:D: )
Returns the name of the code by calling C<name>.
=head2 method Str
method Str( ForeignCode:D: )
Returns the name of the code by calling C<name>.
=end pod
# vim: expandtab shiftwidth=4 ft=perl6
You can’t perform that action at this time.