From hadley at rice.edu  Mon May  2 15:53:45 2011
From: hadley at rice.edu (Hadley Wickham)
Date: Mon, 2 May 2011 08:53:45 -0500
Subject: [Rd] Using substitute to access the expression related to a promise
Message-ID: <BANLkTi=PARrZvyvDJsH4x8GDCY7kLHm+=w@mail.gmail.com>

Hi all,

The help for delayedAssign suggests that you can use substitute to
access the expression associated with a promise, and the help for
substitute says: "If it is a promise object, i.e., a formal argument
to a function or explicitly created using ?delayedAssign()?, the
expression slot of the promise replaces the symbol.

But this doesn't seem to work:

> a <- 1
> b <- 2
> delayedAssign("x", {message("assigning..."); a + b})
> substitute(x)
x
> x
[1] 3

Is this a bug in substitute?

> sessionInfo()
R version 2.13.0 (2011-04-13)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
...

Hadley

-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/



[Rd] Using substitute to access the expression related to a promise
Hadley Wickham