[Rd] [External] exists, get and get0 accept silently inputs of length > 1

iuke-tier@ey m@iii@g oii uiow@@edu iuke-tier@ey m@iii@g oii uiow@@edu
Mon Nov 23 21:50:54 CET 2020


Thanks for the suggestion.

In R-devel (as of r79474) exists(), get(), and get0() now signal an
error if the first argument has length > 1. This will cause about 30
CRAN packages and possibly a couple of Bioconductor packages to fail
under R-devel.

getS3method() now also signals an error if the class argument has
length > 1. Calls of the form getS2method(generic, class(x)) will now
fail if class(x) has length > 1. I believe most CRAN package issues
related to this change have already been resolved, but a few may
remain.

Best,

luke

On Fri, 13 Nov 2020, Antoine Fabri wrote:

> Dear R-devel,
>
> The doc of exists, get and get0 is unambiguous, x should be an object given
> as a character string. However these accept longer inputs. It can lead an
> uncareful user to think these functions are vectorized when they're not,
> and generally lets through bugs that one might have preferred to trigger
> earlier failure.
>
> ``` r
> exists("d")
> #> [1] FALSE
> exists(c("c", "d"))
> #> [1] TRUE
> get(c("c", "d"))
> #> function (...)  .Primitive("c")
> get0(c("c", "d"))
> #> function (...)  .Primitive("c")
> ```
>
> I believe these should either fail, or be vectorized, probably the former.
>
> Thanks,
>
> Antoine
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
Luke Tierney
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa                  Phone:             319-335-3386
Department of Statistics and        Fax:               319-335-3017
    Actuarial Science
241 Schaeffer Hall                  email:   luke-tierney using uiowa.edu
Iowa City, IA 52242                 WWW:  http://www.stat.uiowa.edu



More information about the R-devel mailing list