I have a function that takes (...) as arguments. I want the user to be able to supply the (...) as bare names. The return value of the function should be a named character vector. So:
You can use rlang::exprs(...) as a replacement for eval(subsitute(alist(...))); and I'm not sure why you need the logic inside the if statement (I'm probably missing something).
Either way here's a (marginally) updated version of your working function that produces the same result:
Hmm the documentation of rlang::exprs() even says that it is equivalent to eval(substitute(alist(...))). I am tempted to stay with eval(substitute(alist(...))), since both eval and substitute are internals/primitive, while rlang::exprs() is a convoluted rabbithole of functions if you try to follow the source code down.
Thanks for the tip with as.character() though, I would not have expected that it works that straight forward with names.
I agree with you re: the rabbit hole of functions that you can end up with relying on external packages vs. base functionality sometimes; I suppose in this instance it might be the case that the rabbit hole will get shallower over time as the tidy evaluation framework matures.
And I think the simplification for the as.character() call is just because a named list can be defined with characters or symbols/names for the list names; e.g.
hmm thanks for all the input @mara@edgararuiz . I guess for those solutions I would have to make my whole code use tidyeval (which I don't really have the time for right now). For now i'll stick with the named character vector solution, but i'll keep compat_lazy_dots in mind for later.