Skip to content

Instantly share code, notes, and snippets.

@zoffixznet

zoffixznet/p6.p6 Secret

Created October 25, 2018 18:11
Show Gist options
  • Save zoffixznet/40a07ffad6229ca6b52005f3e799bbde to your computer and use it in GitHub Desktop.
Save zoffixznet/40a07ffad6229ca6b52005f3e799bbde to your computer and use it in GitHub Desktop.
use QAST:from<NQP>;
BEGIN $*LANG.refine_slang: 'MAIN',
role {}, role {
method arglist(Mu $/) {
use nqp;
my \ret := callsame;
my @args;
my \a := $/.made;
my int $els = nqp::elems(a);
my int $i = -1;
nqp::while(
++$i < $els,
nqp::stmts(
(my \arg = nqp::atpos(a, $i)),
@args.push: nqp::if(
nqp::istype(arg, QAST::SpecialArg),
"{arg.named} => " ~ nqp::atpos(arg, 0).value.gist,
nqp::if(
nqp::istype(arg, QAST::Want),
nqp::atpos(arg, 0).value.gist,
nqp::if(
nqp::istype(arg, QAST::Var),
arg.name,
'UNKNOWN')))));
say "Got args: ", @args.join: ", ";
ret
}
}
{
sub foo (|c) { }
foo :42foo, "bar", :10ber;
foo 'meow', :1z, "bar", :10ber
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment