In your case, I think that you want something like the following, wish you an enjoyable amount of hacking!
sub your_stuff(&callback) { ... like pera-int-f before my @parameters := &callback.signature.params; my $signature = Signature.new(params => ( .... Other parameters before Parameter.new( type => Callable, sub-signature => &callback.signature), ... Other parameters after ), returns => int32); } ... like pera-int-f after } From: Vittore Scolari <vittore.scol...@gmail.com> Date: Thursday, 29 August 2019 at 17:48 To: Marcel Timmerman <mt1...@gmail.com>, perl6 users <perl6-us...@perl.org> Subject: Re: nativecall and variable argument lists Hello, Thanks to the amazing job Lizmat did to implement runtime signatures it can be done. You could also probably add some caching of the signatures and the functions. I didn’t benchmark. Here the code: use NativeCall; sub pera-int-f(Str $format, *@args) { state $ptr = cglobal(Str, "printf", Pointer); my $signature = Signature.new( params => ( Parameter.new(type => Str), |(@args.map: { Parameter.new(type => .WHAT) }) ), returns => int32); my &f = nativecast($signature, $ptr); f($format, |@args) } pera-int-f("Pera + Mela = %d + %d %s\n", 25, 12, "cippas");