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

Gabriel Becker g@bembecker @end|ng |rom gm@||@com
Tue Nov 17 05:05:49 CET 2020


Hi all,

I have used variable values in get() as well, and including, I think, in
package code (though pretty infrequently).

Perhaps a character.only argument similar to library?

~G

On Mon, Nov 16, 2020 at 5:31 PM Hugh Parsonage <hugh.parsonage using gmail.com>
wrote:

> I noticed the recent commit to R-dev (r79434).  Is this wise? I've
> often used get() in constructions like
>
> for (j in ls()) if (is.numeric(x <- get(j))) ...
>
> (and often interactively, rather than in a package)
>
> Am I to understand that get(j) will now be equivalent to `j` even if j
> is a string referring putatively to another object?
>
> On Sat, 14 Nov 2020 at 01:34, <luke-tierney using uiowa.edu> wrote:
> >
> > Worth looking into. It would probably cause some check failures, so
> > would probably be a good idea to run a check across BIOC/CRAN.  At the
> > same time it would be worth allowing name objects (type "symbol") so
> > thee don't have to be converted to character for the call and then
> > back to names internally for the environment lookup.
> >
> > 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
> >
> > ______________________________________________
> > R-devel using r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
>
> ______________________________________________
> R-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

	[[alternative HTML version deleted]]



More information about the R-devel mailing list