Comments (10)
FWIW expr()
is more meaningful at a glance than build()
is to me at least. build_expr()
would kind of capture both, though I don't know that it's a great function name. There are also some mental namespace collisions with build()
in terms of R/RStudio commands (surmountable obstacles for sure), but just putting that out thereβ¦ Again, not a function name, but I somehow think of it more as constructing than building (which π, yeah, they're basically synonyms).
Also possible that my mental model is just totally wrong, since you blew my mind yesterday with the enquo()
expr()
thing.
from tidyeval.
I think if we decide to change the names, we need to design some sort of experiment so that we can validate that the new names are actually easier for people to understand. I know that @gvwilson would be very happy to help out with this sort of experiment.
from tidyeval.
Going with the defusing / booby trap analogy:
expr() -> defuse()
enquo() -> arg_defuse()
defuse()
prevents evaluation of your own expression. arg_defuse()
prevents evaluation of a function argument.
defuse()
seems to go well with blast()
:
dfs <- list(mtcars[1:2, 1:4], mtcars[3:4, 1:4])
defuse(rbind(!!!dfs))
#> rbind(<data.frame>, <data.frame>)
blast(rbind(!!!dfs))
#> mpg cyl disp hp
#> Mazda RX4 21.0 6 160 110
#> Mazda RX4 Wag 21.0 6 160 110
#> Datsun 710 22.8 4 108 93
#> Hornet 4 Drive 21.4 6 258 110
from tidyeval.
That's similar to the naming scheme we had in earlier versions of rlang. Some thoughts:
-
Probably not worth renaming
eval_tidy()
which is a very specialised function. -
We should probably steer away from the
tidy_
prefix. If the goal is autocompletion you'll find many disparate functions in that namespace. -
I worry that it's too late to change the names and having two sets of names + friendlyeval is going to make things more complicated.
from tidyeval.
-
I like how
build()
suggests it's building a more complex expression. If we go forbuild()
then we'll have to embrace thequote()
/build()
dichotomy as in lisp. -
Instead of capture, could be
auto_quote()
andauto_quote_list()
.
from tidyeval.
delay_action(arg) # enquo()
delay_variable(arg) # ensym()
as_name(delay_variable(arg))
as_label(delay_action(arg))
from tidyeval.
action <- delay_action(arg)
action <- expand(mean(!!action, na.rm = TRUE))
from tidyeval.
Why do you prefer delay_
over capture_
?
One reason might be to pick an antonym for eval()
and delay()
+ advance()
is more evocative than capture()
+ release()
from tidyeval.
I was thinking about delay_
and resume()
. I'm considering whether explaining NSE in term of delaying of computation may be more intuitive for beginners.
-
Sourcing an R file triggers a series of computation, getting results after results. If a function suspends that process of computation, it gets the blueprint of the computation instead.
-
Why suspend? In order to resume computation with the blueprint in a different context (the user's data).
I think "delaying" instead of "quoting" or "capturing" is more suggestive of why we need to quote. If users understands why, they are more likely to remember what to do the next time around.
The next step is to understand how to change blueprints. It's easy to change results, but to change a blueprint we need !!
. That's the surgical operator that allows you to modify a blueprint. When you're dealing with code as text, the surgical operator is %s
or { }
. When you're dealing with code as blueprint, it's !!
.
Finally, what are blueprints made of: variables (symbols) and actions (function calls). Though I'm not entirely happy with delay_action()
because that suggests it always returns calls, just like delay_variable()
always returns symbols.
from tidyeval.
Funnily enough, I was just discussing this with Andy Stefik...
from tidyeval.
Related Issues (18)
- Glossary HOT 1
- An idea: Introduce quoting as a expression/data transformation from the beginning HOT 10
- Functions forwarding inputs to select() and a mutate- or filter-like function
- Explore arrange implementation HOT 1
- mutate_front()
- Why data masking
- Add GitHub link and/or edit link
- tidy eval terms and functions <--> base R terms and functions
- (en)quo(s) vs (en)sym(s) HOT 3
- Use one Rmd file per chapter
- Tangling with dots
- "How to see what's going on" HOT 2
- Polite request to add examples for select and filter HOT 3
- Rephrasing of sentence
- How can we take inputs that should strictly be column names?
- dplyr: working with character vectors of column names HOT 1
- Replace quote() by expr()
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tidyeval.