[Rd] An inconsistency with promise in attributes

Saikat DebRoy saikat at stat.wisc.edu
Mon Aug 11 13:23:10 MEST 2003


When an attribute is a delayed expression sometimes it is not forced 
when it is extracted.

 > x <- list()
 > attr(x, "p") <- delay(1)
 > x
list()
attr(,"p")
<promise: 0x11e4bb8>
 > val <- attr(x, "p")
 > val
[1] 1
 > attr(x, "p")
<promise: 0x11e4bb8>

I am not quite sure whether the above is a bug or not but I think the 
following is a bug - a promise is supposed to give its value once 
evaluated!

 > eval(attr(x, "p"))
<promise: 0x11e4bb8>



More information about the R-devel mailing list