I'm wondering how functions like
tidyselect::everything() do to error when executed outside the desired scope/environment. If I understand correctly,
everything() will check whether or not data exist in a predefined environment (
vars_env here which is defined in the package environment). If the data exist, the function proceeds, otherwise it throws an error. What I don't get though, is when, where and how
everything() is evaluated.
Considering the following code:
mutate(a_tibble, across(everything(), as.character))
I'd normally expect
everything() to be evalutated first,
across() second and
mutate() last. Since the data doesn't exist in
everything()'s environment, I'd then expect the line above to fail everytime.
I couldn't find in the source code where the data is passed to
vars_env. I'd assume it happens within
mutate(), which then would mean the way evaluation occurs in the code above is opposite of what I thought.
Any hints to help me understand how all this works?