[Rd] Inspecting promises

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Sun, 23 Sep 2007 21:31:01 -0400


Is there some way of displaying the expression and evaluation environment associated with a promise? I have found the following:

> # first run these two commands to set up example
> e <- new.env()
> delayedAssign("y", x*x, assign.env = e)

> # method 1. shows expression but not evaluation environment
> str(as.list(e))

List of 1
 $ y: promise to language x * x

> # method 2. shows expression but not evaluation environment
> substitute(y, e)

x * x

which shows two different ways of displaying the expression associated with a promise but neither shows the evaluation environment. The first technique may actually be a bug in R based on previous discussion on r-devel.

Is there a way to display both the expression and the evaluation environment associated with a promise. Its a bit difficult to debug code involving promises if you can't inspect the objects you are working with.

> R.version.string # Vista
[1] "R version 2.6.0 beta (2007-09-19 r42914)"



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Mon 24 Sep 2007 - 01:32:45 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 25 Sep 2007 - 00:41:31 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.