[graalvm-users] Fwd: Re: Named parameters

Stepan stepan.sindelar at oracle.com
Sat Jun 16 02:04:18 PDT 2018


Forgot to include the list.

-------- Forwarded Message --------
Subject: Re: [graalvm-users] Named parameters
Date: Sat, 16 Jun 2018 11:01:19 +0200
From: Stepan <stepan.sindelar at oracle.com>
To: Rodrigo Botafogo <rodrigo.a.botafogo at gmail.com>

Hi Rodrigo,

you've raised a good point. AFAIK the API does not allow to pass in 
parameter names, so you can only use R's positional matching -- provide 
values (use the defaults) for any preceding arguments up to the argument 
you want to use.

However, 'paste' is particularly tricky, because it takes ellipsis (...) 
as the first argument, so AFAICS there's no way to match the rest of the 
arguments positionally.

R:
> paste
function (..., sep = " ", collapse = NULL)

So in this case, your only chance is to create wrapper that can take 
those arguments positionally:

Ruby:
> p Polyglot.eval("R", "function(collapse, ...) paste(list(...), 
collapse = collapse)").call(",", "hello", "world")

Regards,
Stepan


On 15/06/18 23:21, Rodrigo Botafogo wrote:
> Hello,
> 
> R has named parameters, such as:
> 
> paste("Hello", "world", collapse = ",")
> 
> Is there any way to pass this named parameter (collapse) through the 
> call interface?
> 
> p = R.eval("paste")
> p.call("hello", "world", ???)
> 
> Thanks
> 
> -- 
> Rodrigo Botafogo
> 
> 
> 
> _______________________________________________
> GraalVM-Users mailing list
> GraalVM-Users at oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/graalvm-users
> 



More information about the GraalVM-Users mailing list