I am trying to use multi in my Raku code that wraps a function in C.
Here I am calling lchoose function in shared libray Rmath.
This is my code which works:
use NativeCall;
constant RMATH = "./Rmath"; # shared library
sub lchoose(num64, num64) returns num64
is native( RMATH ) { * };
# The C function signature is
# double lchoose(double, double);
sub r_lchoose($n,$r) {
return lchoose($n.Num, $r.Num)
}
say r_lchoose(9,8) # 2.1972245773362196
But this does not work. The code keeps on running/hanging. Neither dies nor throws any output:
use NativeCall;
constant RMATH = "./Rmath"; # shared library
multi lchoose(num64, num64) returns num64
is native( RMATH ) { * };
multi lchoose($n,$r) {
lchoose($n.Num, $r.Num)
}
say lchoose(9,8) # Neither dies nor throws any output
My expectation is when I call lchoose(9,8) it should call second multi as the arguments are definitely not num64. If it had used second function, then it would have called the first function and given the output.
Or atleast I expected the program to throw error rather than hang.
OS information
Windows 11 64-bit
Raku information
Welcome to Rakudo™ v2022.04.0000.1.
Implementing the Raku® Programming Language v6.d.
Built on MoarVM version 2022.04-3-ga9fcd5a74.