feature request: support curly braces in eg. path()
torbjorn opened this issue · 3 comments
Would be nice to be able to do:
horse <- "silver"
my_path <- path("hi", "ho", "{horse}_away")
... So we don't have to do additional glue's on every element of the path. One could quickly feel tempted to just glue the whole thing then, which would be unfortunate.
We cannot do that, that is a breaking change. If you like, you can write a helper function, that calls glue for each element, and then creates a path from the results.
If you do that, note that {}
characters are allowed in file paths, so be carefule not to call your helper function on variables from the user, as they may contain {}
characters.
Yes, that makes sense
Would it be feasible to adopt a pathg
(or similar) function for this into fs? Curly brace notation is already making it's way into multiple packages in tidyverse.
But it's also a design philosophy change that likely means a pletora of functions in fs now would be expected to have a g
sister function for glue extrapolation, so it's probably a too big ask.
Yeah, I don't think that's a good way forward. That would mean that we should add a *g()
variant to pretty much every function that takes string or character inputs, in all of our packages.
Ideally, R would support this natively, with new syntax. Many languages have made that change. E.g., similarly to the new r"{....}" raw strings, R could have
f"..."that interpolates
{expr}` expressions.