[R] how do you know which functions are being debugged?
Steve Lianoglou
mailinglist.honeypot at gmail.com
Sat Oct 24 01:28:17 CEST 2009
Sweet Jesus ... I just read what I wrote earlier ...
On Oct 23, 2009, at 2:57 PM, Steve Lianoglou wrote:
> If this is something you just want to use on your own functions that
> are set to `debug`, why not just make write a debug wraps the
> base::debug and does some keeps track of which functions you're
> debugging in some global environment variable (of your creation).
This has to win for one of my most lucid moments.
I feel like I should publicly apologize for letting such an
abomination out of its cage. Hopefully the code I sent explained what
my feeble attempt at "human communication" didn't ... yeesh!
Sorry :-)
-steve
> You should probably use something beside "substitute" here, but:
>
> R> .DLIST <- character()
> R> debug <- function(fun, text="", condition=NULL) {
> .DLIST <<- c(.DLIST, substitute(fun))
> base::debug(fun, text=text, condition=condition)
> }
>
> R> myfun <- function(something) {
> a <- length(something)
> b <- sum(something)
> b
> }
>
> R> debug(myfun)
> R> debug(myfun)
> R> .DLIST
> [[1]]
> myfun
>
> R> myfun(1:10)
> debugging in: myfun(1:10)
> debug: {
> a <- length(something)
> b <- sum(something)
> b
> }
> Browse[2]> n
> debug: a <- length(something)
> Browse[2]> n
> debug: b <- sum(something)
> Browse[2]> n
> debug: b
> Browse[2]> n
> exiting from: myfun(1:10)
> [1] 55
--
Steve Lianoglou
Graduate Student: Computational Systems Biology
| Memorial Sloan-Kettering Cancer Center
| Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact
More information about the R-help
mailing list