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

Fix NSE issues #2569

Merged
merged 19 commits into from
Mar 24, 2017
Merged

Fix NSE issues #2569

merged 19 commits into from
Mar 24, 2017

Conversation

lionel-
Copy link
Member

@lionel- lionel- commented Mar 24, 2017

@lionel- lionel- mentioned this pull request Mar 24, 2017
@lionel- lionel- requested a review from hadley March 24, 2017 11:53
R/count-tally.R Outdated
sum(!! wt, na.rm = TRUE)
}
)
if (is_empty_quosure(wt) || is_null(f_rhs(wt))) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quo_is_missing(wt) || quo_is_empty(wt)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's not the naming scheme we've followed so far. It's not clear what is best to do in these cases. Same issue occurs with set_ and mut_ functions. Currently rlang does not type-prefix all these functions.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we had been pretty consistent with a type prefix. I think it would help here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these would be the very first predicates prefixed with a type in rlang.

This is linked to the issue of automatically taking the RHS in all language predicates. E.g. is_symbol() is shortcut for is_symbol(f_rhs(x)). I think this works mostly fine but is confusing because not all rlang predicates behave this way. An alternative would be a set of quosure-specific predicates. Then it probably makes sense to prefix all of them with quo, e.g. quo_is_null(), quo_is_symbol().

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we combined them both into quo_is_empty()? Then it's a specific definition of emptiness that applies primarily to quosures.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm I think we should be consistent with base R, otherwise this will be confusing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm I think we should be consistent with base R, otherwise this will be confusing.

maybe is_empty_quosure() needs to be quo_is_missing() then?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's just awkwardness in the design of count(): most functions would either check for missingness or NULL, not both. And missingness is probably what needs a special predicate.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these functions are definitely awkardly designed, but at least they pointed our attention to missing quosures and literal rewrapping :)

R/count-tally.R Outdated
}
)
if (is_empty_quosure(wt) || is_null(f_rhs(wt))) {
n <- ~n()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should use quo() here, just to be consistent

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking we should only use quo() when we need to unquote something, so this provides additional intent in the code. This rule would not apply in introductory texts.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think simplicity wins over the minor signal loss.

R/funs.R Outdated
names(funs) <- names2(funs)
missing_names <- names(funs) == ""
default_names <- map_chr(funs[missing_names], function(dot) {
quo_text(node_car(f_rhs(dot)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use quo_name() here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want to allow unquoting literal functions there.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this line just determining the default name?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes but quo_name() will abort with literal inputs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only if they're length >1 ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh that makes sense, expr_name() needs to be changed then

@lionel- lionel- merged commit 8e53a90 into tidyverse:master Mar 24, 2017
@lionel- lionel- deleted the fix-nse branch November 7, 2017 10:14
@lock
Copy link

lock bot commented Jan 18, 2019

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

@lock lock bot locked and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants