rlang
rlang copied to clipboard
Clarification on .homonyms?
Hi
I have trouble understanding the use of .homonyms
in enquos()
. I thought it would keep/filter arguments of the same name, which I understand to be inputs in ...
. Now it does not seem to be the case, but I probably misunderstood the function? Could you please give a specific example of the use of .homonyms
.
More generally, I was trying to get only "unique" expressions out of list of quosures, is .homonyms
relevant in that case?
Thanks!!
library(rlang)
packageVersion("rlang")
#> [1] '0.4.6'
fo <- function(x_var=Species){
rlang::enquos(x_var,x_var, .homonyms = "error", .named=TRUE)
}
fo()
#> <list_of<quosure>>
#>
#> $Species
#> <quosure>
#> expr: ^Species
#> env: 0x55fd5ddcd3e8
#>
#> $Species
#> <quosure>
#> expr: ^Species
#> env: 0x55fd5ddcd3e8
fo2 <- function(...){
rlang::enquos(..., .homonyms = "error", .named=TRUE)
}
fo2(Species, Species)
#> <list_of<quosure>>
#>
#> $Species
#> <quosure>
#> expr: ^Species
#> env: global
#>
#> $Species
#> <quosure>
#> expr: ^Species
#> env: global
Created on 2020-06-23 by the reprex package (v0.3.0)
This is a bug, you can use quos()
in the mean time (it supports capturing dots but not named arguments).