On 06/30/2009 10:35 AM, Thomas Friedrichsmeier wrote:
> On Monday 29 June 2009, Romain Francois wrote:
>    
>> I'm attaching a patch that prints this instead:
>>   >  ls.str()
>>
>> xx :<active binding>
>>
>> Although a better behaviour would be to show the binding function.
>>      
>
> I can see your point, but note that active bindings are not necessarily slow,
> and a special treatment may not be desirable in all use cases. For instance in
> RKWard, we use active bindings to detect, when objects are modified. To do so,
> we move *al* objects from .GlobalEnv to a hidden storage environment, and
> place corresponding active bindings in .GlobalEnv, instead. So, in our case,
> we'd clearly like for active bindings to behave just like regular objects, as
> much as possible.
>
> Regards
> Thomas
>    

Hi Thomas,

Not sure your trick is full-proof. What happens when the variable you 
copy is already an active binding ? There should be another way to track 
changes.

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.
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 ?

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

 > delayedAssign( "foobar", { Sys.sleep(5); rnorm(10) } )
 > typeof( foobar ) # takes 5 seconds
[1] "double"

Romain

-- 
Romain Francois
Independent R Consultant
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr



        [[alternative HTML version deleted]]

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to