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

FR: julia style self-naming args #1625

Open
t-kalinowski opened this issue May 15, 2023 · 0 comments
Open

FR: julia style self-naming args #1625

t-kalinowski opened this issue May 15, 2023 · 0 comments

Comments

@t-kalinowski
Copy link
Member

t-kalinowski commented May 15, 2023

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)
fn(a, b, ~..., c, d)

Edit:

I suppose an approximation is possible today with:

named <- function(...) dots_list(.named = TRUE, ...) 
fn(a, b, !!!named(c, d))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant