Hello,

Should active binding appear as such in ls.str.

> makeActiveBinding( "xx", function(arg){ Sys.sleep(10) }, .GlobalEnv )
> ls.str() # takes 10 seconds
xx :  NULL

What we see here is the result of the "setter" of the binding.

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.

Romain

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


Index: src/library/utils/R/str.R
===================================================================
--- src/library/utils/R/str.R   (revision 48872)
+++ src/library/utils/R/str.R   (working copy)
@@ -544,14 +544,18 @@
 ##__       str(get(nam, envir = E, mode = M),
 ##__           max.level = max.level, give.attr = give.attr, ...)
 
-       o <- tryCatch(get(nam, envir = E, mode = M), error = function(e)e)
-       if(inherits(o, "error")) {
-           if(length(grep("missing|not found", o$message)))
-               cat("<missing>\n")
-           else stop(o$message)
+       if( bindingIsActive( nam, E) ){
+               cat( "<active binding>\n" )
+       } else{
+               o <- tryCatch(get(nam, envir = E, mode = M), error = 
function(e)e)
+               if(inherits(o, "error")) {
+                   if(length(grep("missing|not found", o$message)))
+                       cat("<missing>\n")
+                   else stop(o$message)
+               }
+               else
+                   do.call(str, c(list(o), strargs))
+       }
        }
-       else
-           do.call(str, c(list(o), strargs))
-    }
     invisible(x)
 }
______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to