Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Callables do not support keyword arguments #165

Closed
devmotion opened this issue May 7, 2021 · 3 comments
Closed

Callables do not support keyword arguments #165

devmotion opened this issue May 7, 2021 · 3 comments

Comments

@devmotion
Copy link

Callables do not support keyword arguments currently:

> library(JuliaCall)
> julia_setup()
> julia_command("struct Callable end")
> julia_command("(::Callable)(x...; a=3.0, b=2) = print(\"a=\", a, \", b=\", b)")
> r <- julia_eval("Callable()")
> r$.(1, 2, 3, a=3.2)
Error: Error happens in Julia.
MethodError: no method matching apply(::Callable, ::Float64, ::Float64, ::Float64; a=3.2)
Closest candidates are:
  apply(::Any, ::Any...) at /home/david/R/x86_64-pc-linux-gnu-library/4.0/JuliaCall/julia/setup.jl:233 got unsupported keyword argument "a"
Stacktrace:
 [1] docall(call1::Ptr{Nothing})
   @ Main.JuliaCall ~/R/x86_64-pc-linux-gnu-library/4.0/JuliaCall/julia/setup.jl:168
> sessionInfo()
R version 4.0.5 (2021-03-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Arch Linux

Matrix products: default
BLAS:   /usr/lib/libopenblasp-r0.3.14.so
LAPACK: /usr/lib/liblapack.so.3.9.1

locale:
 [1] LC_CTYPE=en_US.UTF-8          LC_NUMERIC=C                 
 [3] LC_TIME=en_US.UTF-8           LC_COLLATE=en_US.UTF-8       
 [5] LC_MONETARY=en_US.UTF-8       LC_MESSAGES=en_US.UTF-8      
 [7] LC_PAPER=en_US.UTF-8          LC_NAME=en_US.UTF-8          
 [9] LC_ADDRESS=en_US.UTF-8        LC_TELEPHONE=en_US.UTF-8     
[11] LC_MEASUREMENT=en_US.UTF-8    LC_IDENTIFICATION=en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] JuliaCall_0.17.2

loaded via a namespace (and not attached):
[1] compiler_4.0.5 tools_4.0.5    Rcpp_1.0.6     knitr_1.31     xfun_0.22
@devmotion
Copy link
Author

I'd like to help to fix this issue if it is feasible since I'd like to change the API of my package without dropping support for R, but unfortunately I don't know where to look and where to start in JuliaCall.

Non-Contradiction added a commit that referenced this issue Jul 13, 2021
@Non-Contradiction
Copy link
Collaborator

Thank you very much for the feedback and the use of JuliaCall for your package!

I just made a commit that should fix the problem.
The fix is quite straightforward. The message in the traceback

apply(::Any, ::Any...) at /home/david/R/x86_64-pc-linux-gnu-library/4.0/JuliaCall/julia/setup.jl:233 got unsupported keyword argument "a"

points out to the lines in setup.jl that the original apply function does not support keyword arguments.
https://github.com/Non-Contradiction/JuliaCall/blob/6431e0eca7e0c3f8b073d8dce2fcaa1beceddd88/inst/julia/setup.jl#L241-L243
So I just made a little modification to the function to accept keyword arguments.

@devmotion
Copy link
Author

Great, thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants