-
Notifications
You must be signed in to change notification settings - Fork 187
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
Extend assignment_operator to optionally allow '=' assignments #2698
base: main
Are you sure you want to change the base?
Conversation
From an interface standpoint I think Maybe it's worth exploring what |
I agree that we shouldn't support "any" as an option. That is effectively turning off the linter, which they can already do via the config file. |
Well, not exactly. It would still retain the remaining options -- even if we subsume all of But maybe
I didn't like the redundancy of
I really wanted to punt here to make progress on this linter in the next release & enable using Using anything but |
I like the sound of NULL can't be included in |
what would NA mean? I was thinking 'NULL<->any operator' so it wouldn't need to be mixed with other strings & could be handled separately. |
|
I see, basically it's to facilitate
I think I'm not sure there's much expositional difference between stating " |
Imho, But in base, both are used as way to get some default behaviour or turn out the behaviour completely. I would probably not put |
In {base}, there's most saliently NULL # ensure .Last.value is NULL
getNamespaceExports('base') |>
sapply(function(fn) {
f <- get(fn)
if (!is.function(f)) return(FALSE)
f |>
formals() |>
sapply(\(arg) is.atomic(arg) && length(arg) == 1L && is.na(arg)) |>
any()
}) |>
which() |>
length() 37 more in other default packages. |
Yes, but correct me if I am wrong, but those are for single value. For instance, various plot options take some default value if they are NULL, but can be suppressed with NA (e.g., I haven't seen NA in multiple options. opts = c("foo", "bar", NA) # NA converted to NA_character_ so fine
match.arg(NA, opts) # Error ... : 'arg' must be NULL or a character vector
match.arg(NA_character_, opts) # fine! Maybe you have mentioned this in #2698 (comment), its a late here. |
Closes #2441. Tests are partially copied from #2521 -- for implementation I'm starting from scratch rather than trying to re-work it based on the discussion there. Thanks @J-Moravec for getting things started & the fruitful discussion!
Pausing here for, well, even more discussion :)
I'm getting hung up on the interaction of the proposed argument with the other arguments, particularly
allow_right_assign
andallow_pipe_assign
.If we have
(allow_right_assign=FALSE, top_level_operator="any")
, that does makex -> 2
a bit ambiguous, right?I can think of two options:
top_level_operator = c("<-", "->", "%<>%")
to be equivalent to the current(allow_right_assign=TRUE, allow_pipe_assign=TRUE)
. That looks pretty transparent to me, but presents some back-compatibility issues.any
in favor ofeither
, i.e. either<-
or=
.WDYT @IndrajeetPatil @AshesITR?