From ggrothendieck at gmail.com  Sun Oct 29 14:03:27 2006
From: ggrothendieck at gmail.com (Gabor Grothendieck)
Date: Sun, 29 Oct 2006 08:03:27 -0500
Subject: [Rd] how to determine if a function's result is invisible
In-Reply-To: <4543FB75.7090405@stats.uwo.ca>
References: <971536df0610251714u451cf80fy80bf38cb2f130734@mail.gmail.com>
	<454023EA.4020403@stats.uwo.ca>
	<971536df0610252002s46ef72b2n32df3e180a49e990@mail.gmail.com>
	<45403561.1000808@stats.uwo.ca>
	<971536df0610260226o55726354j8cbdfa5af07ae508@mail.gmail.com>
	<45438F9B.7000905@stats.uwo.ca> <4543D3A6.7010900@sciviews.org>
	<4543FB75.7090405@stats.uwo.ca>
Message-ID: <971536df0610290503m9e653caoe0b14b077319d4cc@mail.gmail.com>

On 10/28/06, Duncan Murdoch <murdoch at stats.uwo.ca> wrote:
> On 10/28/2006 6:03 PM, Philippe Grosjean wrote:
> > Duncan Murdoch wrote:
> > [...]
> >> I've just added this function to R-devel (to become 2.5.0 next spring):
> >>
> >> withVisible <- function(x) {
> >>      x <- substitute(x)
> >>      v <- .Internal(eval.with.vis(x, parent.frame(), baseenv()))
> >>      v
> >> }
> >>
> >> Luke Tierney suggested simplifying the interface (no need to duplicate
> >> the 3 parameter eval interface, you can just wrap this in evalq() if you
> >> need that flexibility); the name "with.vis" was suggested, but it looks
> >> like an S3 method for the with() generic, so I renamed it.
> >>
> >> Duncan Murdoch
> >
> > Excellent, many thanks... but I am afraid I cannot use this function
> > because you force evaluation on parent.frame(), where I need to evaluate
> > it in .GlobalEnv (which is NOT equal to parent.frame() in my context).
> > Would it be possible to change it to:
> >
> > withVisible <- function(x, env = parent.frame()) {
> >      x <- substitute(x)
> >      v <- .Internal(eval.with.vis(x, env, baseenv()))
> >      v
> > }
> >
> > ...so that we got additional flexibility?
>
> As I said, that's not needed.  Use evalq(withVisible(x), envir=.GlobalEnv).

Even if its not strictly necessary in terms of minimality it still might be
convenient and consistent with other eval-style functions which do tend
to provide an env= or in the case of lm-style functions a data= argument.
Also its very easy to do and the underlying internal function supports it.




[Rd] how to determine if a function's result is invisible
Gabor Grothendieck