On 06/30/2009 11:41 AM, Thomas Friedrichsmeier wrote:
> 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.
>
This was more of a question. I'd like to know if there is a way for
objects to broadcast that they have changed.
This would be very useful to for example implement an object browser in
a front-end, which I guess is part of the reason for the trick ?
>> 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).
>
The problem is as soon as you pass it to a function, you force the
promise, maybe passing the symbol instead could do the trick, but I have
not seen something that brings the information that an object is a
promise. Maybe you are right and I am not supposed to play with them ...
> Regards
> Thomas
>
--
Romain Francois
Independent R Consultant
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel