[Rd] active bindings and ls.str

Thomas Friedrichsmeier thomas.friedrichsmeier at ruhr-uni-bochum.de
Tue Jun 30 11:41:34 CEST 2009


Hi,

On Tuesday 30 June 2009, Romain Francois wrote:
> Not sure your trick is full-proof. What happens when the variable you
> copy is already an active binding ?

see promises, below.

> There should be another way to track
> changes.

I'm open to suggestions.

> It is more about seeing what the object really is than speed. I feel we
> don't see the actual object with the current ls.str.

Hm, but isn't that the point of active bindings (and promises), that they are 
just a transparent layer, and the "actual" object *is* the result of 
evaluating the object? (I'm not really qualified to answer that, but that's the 
way I'm thinking about these concepts).

> I would also argue the same about promises:
>  > delayedAssign( "foobar", { Sys.sleep(5); rnorm(10) } )
>  > ls.str() # takes 5 seconds
>
> foobar :  num [1:10] -0.288 0.827 -0.466 -0.803 -1.622 ...
>
> Maybe the promise does not have to forced at that stage. Thomas, does
> rkward's trick force the promise when the make your copy to the hidden
> environment or later ?

On the C level it's possible (and in fact quite easily) to copy the object "as 
is". That's what we do. Including any active bindings and "unseen" promises. 
See our function doCopyNoEval() in RKWard's rembedinternal.cpp .

> BTW, is there a way to identify an object as a promise ?

Once again, this is possible on the C level:
    TYPEOF (object) == PROMSXP               // a promise
    PRVALUE(object) == R_UnboundValue	   // not yet forced
but when I once looked, I did not find any R level facility for this (and my 
guess is that this is hidden on purpose).

Regards
Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
URL: <https://stat.ethz.ch/pipermail/r-devel/attachments/20090630/36e99890/attachment.bin>


More information about the R-devel mailing list