r-lib / rlang

Low-level API for programming with R
https://rlang.r-lib.org
Other
498 stars 136 forks source link

FR: julia style self-naming args #1625

Open t-kalinowski opened 1 year ago

t-kalinowski commented 1 year ago

Julia has a really neat syntax for self naming of args, where

fn(a, b; c, d) 

is the same as

fn(a, b, c=c, d=d)

rlang already has support for self-naming args in rlang::dots_list() and rlang::list2(). It would be great if R users could opt into the self naming args semantics to avoid spelling out some argument names twice.

I'm not sure what syntax would be concise, convenient, readable, and make it past the R parser. Maybe something like:

fn(a, b, .~., c, d)
fn(a, b, ~..., c, d)