From: Gabor Grothendieck <ggrothendieck_at_gmail.com>

Date: Wed, 19 Sep 2007 20:05:26 -0400

R-devel_at_r-project.org mailing list

https://stat.ethz.ch/mailman/listinfo/r-devel Received on Thu 20 Sep 2007 - 00:06:52 GMT

Date: Wed, 19 Sep 2007 20:05:26 -0400

- Is there some way to copy a promise so that the copy has the same expression in its promise as the original. In the following we y is a promise that we want to copy to z. We want z to be a promise based on the expression x since y is a promise based on the expression x. Thus the answer to the code below is desired to be z=2 but its 1, 1 and y in the next three examples so they are not the answer. See examples at end.
- Is there some way to determine if a variable holds a promise without evaluating it?

This code relates to question 1.

# example 1

x <- 0

delayedAssign("y", x)

x <- 1

# this forces y which is not what we want

z <- y

x <- 2

z # 1

*# example 2
*

# this connects to z to x via y which is not what we want

# since if y is forced then z takes its value from that, not x

x <- 0

delayedAssign("y", x)

delayedAssign("z", y)

x <- 1

y

x <- 2

z # 1

*# example 3
**# this attempts to assign the expression underlying promise y to z
*

# which seems closest in spirit to what we want

# but it does not work as intended

x <- 0

delayedAssign("y", x)

delayedAssign("z", substitute(y))

x <- 1

y

x <- 2

z # y

> R.version.string # Vista

[1] "R version 2.6.0 alpha (2007-09-06 r42791)"

R-devel_at_r-project.org mailing list

https://stat.ethz.ch/mailman/listinfo/r-devel Received on Thu 20 Sep 2007 - 00:06:52 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 Thu 20 Sep 2007 - 20:42:15 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.
*