[R] how do you know which functions are being debugged?

Gabor Grothendieck ggrothendieck at gmail.com
Fri Oct 23 20:39:17 CEST 2009


On Fri, Oct 23, 2009 at 2:34 PM, Duncan Murdoch <murdoch at stats.uwo.ca> wrote:
> On 10/23/2009 2:27 PM, Gabor Grothendieck wrote:
>>
>> I have often wanted to get such a list as well without having to write
>> code myself.  If  a function which automatically iterated over all
>> possible objects and listed out the ones that being debugged were
>> available in the core it would be useful.  Even if its slow this would
>> be used at debug time and not a production time so it would not be too
>> bad.  Even a heuristic that checked likely locations, e.g. just the
>> global environment, but not all locations might be useful.
>
> If you look at the code in setBreakpoint, it does a search for functions in
> lots of places (but not everywhere).  You could start from that.
>
> Generally speaking, it's quite hard to think of a way to express what the
> answer would look like to a perfectly general function like you're asking
> for.  Suppose a function lives in the parent environment of the environment
> of an expression that was returned in the result of a call to lm that is a
> local variable in the function that called the function where you are asking
> the question:  how would you return that as an answer???  In a language with
> pointers, you'd just return a pointer to it, but R doesn't have those.

I agree its problematic but it would still be useful since after you
have debugged a number of functions its easy to forget which ones are
being debugged.




More information about the R-help mailing list