rstudio/rstudio — pull request #47 by jmcphers (2013-08-21 20:24:30+00:00)
Title: Improve environment pane handling of large objects and long vectors

This change includes the following fixes:

- Support for long vectors. These were previously problematic primarily because we called `Rf_length` directly. I've moved a large chunk of the variable description logic from C++ to R, which allows us to just use R's `length()` without creating a need for us to know about and depend upon this particular R internal.

- Improved handling of large objects. When an object is large, we no longer do anything that directly accesses its value (e.g. calling `str()`). Instead, we print the class, element count, and size--e.g. "Large list (129 elements, 8.5 Mb)". The threshold for large objects is set somewhat arbitrarily at 500K.

- Quieting errors from `str()`. Previously if `str()` threw an error we'd print it to the console; since `str()` is not perfect it does throw errors in some edge cases (Hadley has found some S4 MethodDescriptions it chokes on). We now eat these since the errors aren't user actionable.

- Improved handling of pathological objects. It is no longer necessary in most cases to pass the `SEXP` representing an object through the RStudio -> R interface, so language objects and symbols are now more robust. (Hadley has supplied an ample number of pathological objects over the last few months. :-))

- Minor UI improvements--when an object's value experiences a simple change, its cell in the environment pane will pulse light blue very briefly. (This might be too noisy, let's talk about whether this is useful or the right treatment). Object tooltips now also include the size of the object.

One other note on long vectors: It is possible that we'll have to fix `r::sexp::length` and/or all our direct use of `Rf_length` so that large vectors can be safely passed through any RStudio codepath, but a brief audit turned up no usage of these functions in places where a long vector `SEXP` seems useful and/or likely. If you do think that this is something we need to undertake, happy to do so.