Skip to content
Prev 45876 / 63424 Next

Substitute unaware when promise objects are evaluated

On 13-05-15 11:54 AM, McGehee, Robert wrote:
I think you misunderstand promises.

A promise has two (or three, depending how you count) parts:  an 
expression with an associated environment, and a value.  The value isn't 
filled in until the expression is evaluated, but the expression doesn't 
go away then.  You can still see it until you change the variable that 
holds the promise.
The documentation for substitute may not be clear on this, but for a 
promise, the env argument will be ignored.  It was the eval.env argument 
to delayedAssign that set the promise's environment.
Not at R level. In C code you could, but you probably shouldn't.  Think 
of promises as values where you can look up the expression that gave the 
value, and sometimes delay the calculation until you need it.

Duncan Murdoch