[Rd] RFC: getifexists() {was [Bug 16065] "exists" ...}
Peter Haverty
haverty.peter at gene.com
Fri Jan 9 19:56:44 CET 2015
Fantastic. I'm eager to try it out. Thanks for seeing this through.
Regards,
Pete
____________________
Peter M. Haverty, Ph.D.
Genentech, Inc.
phaverty at gene.com
On Fri, Jan 9, 2015 at 7:37 AM, Martin Maechler <maechler at stat.math.ethz.ch>
wrote:
> >>>>> Martin Maechler <maechler at stat.math.ethz.ch>
> >>>>> on Fri, 9 Jan 2015 14:00:38 +0100 writes:
>
> >>>>> Michael Lawrence <lawrence.michael at gene.com>
> >>>>> on Thu, 8 Jan 2015 14:02:26 -0800 writes:
>
> >> On Thu, Jan 8, 2015 at 11:57 AM, <luke-tierney at uiowa.edu> wrote:
> >>> On Thu, 8 Jan 2015, Michael Lawrence wrote:
> >>>
> >>> If we do add an argument to get(), then it should be named
> consistently
> >>>> with the ifnotfound argument of mget().
>
> You are right... I forgot to say so earlier in the thread.
>
> The definition now is
>
> get0 <- function (x, envir = pos.to.env(-1L), mode = "any", inherits =
> TRUE,
> ifnotfound = NULL)
> .Internal(get0(x, envir, mode, inherits, ifnotfound))
>
>
>
> >>>> As mentioned, the possibility of a
> >>>> NULL value is problematic. One solution is a sentinel value that
> indicates
> >>>> an unbound value (like R_UnboundValue).
> >>>>
> >>>
> >>> A null default is fine -- it's a default; if it isn't right for a
> >>> particular case you can provide something else.
> >>>
>
> [..................]
>
> >>> Adding getIfExists, or .get, or get0, or whatever seems fine.
> Adding
> >>> an argument to get() with missing giving current behavior may be OK
> >>> too. Rewriting exists and get as .Primitives may be sufficient
> though.
>
> > Thank you, Luke. Given that, Duncan's and the other inputs,
> > I think we should go for a new function -- .Internal() for now.
>
> > To Pete's point about arguments, I did drop 'frame' on purpose
> > and indeed we could try to do away with 'where/pos' as well and
> > have the environment only specified by 'envir'.
>
> > Name: I like get0() for its brevity and prefer it to .get().
>
> > Let me expose my current implementation on R-devel ... and start
> > using it in the 'methods' package so we (Pete H. :-) can start
> > measuring its impact.
>
> I have now committed get0() to R-devel (svn rev 67386)
>
> which is already using it in quite a few places:
> in 'base', notably in base/R/namespace.R where it may speedup, also
> in 'methods' in quite a few places also in the hope of some S4
> speedup.
>
> {{Now I feel having deserved some weekend break ...}}
>
> Martin
>
> ______________________________________________
> R-devel at 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