Philippe Grosjean
2001-Oct-09 08:35 UTC
[R] list of functions flagged with debug() or trace()
Hello all, Since I got no answer to my first mail, I suspect I did not formulate my question adequately, so I try again. In R, one can debug or trace a function 'foo' with debug(foo) or trace(foo), respectively. This leads to a special treatment of the function 'foo' until one enter undebug(foo) or untrace(foo). I would like to know if there is a convenient way to know at any time which are the function flagged with debug() or trace() in a R session. Thank you, Cheers, Philippe Grosjean ...........]<(({?<...............<?}))><............................... ) ) ) ) ) __ __ ( ( ( ( ( |__) | _ ) ) ) ) ) | hilippe |__)rosjean ( ( ( ( ( Marine Biol. Lab., ULB, Belgium ) ) ) ) ) __ ( ( ( ( ( |\ /| |__) ) ) ) ) ) | \/ |ariculture & |__)iostatistics ( ( ( ( ( ) ) ) ) ) e-mail: phgrosje at ulb.ac.be or phgrosjean at sciviews.org ( ( ( ( ( SciViews project coordinator (http://www.sciviews.org) ) ) ) ) ) tel: 00-32-2-650.29.70 (lab), 00-32-2-673.31.33 (home) ( ( ( ( ( ) ) ) ) ) "I'm 100% confident that p is between 0 and 1" ( ( ( ( ( L. Gonick & W. Smith (1993) ) ) ) ) ) ....................................................................... -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Tue, 9 Oct 2001, Philippe Grosjean wrote:> Hello all, > > Since I got no answer to my first mail, I suspect I did not formulate my > question adequately, so I try again. > > In R, one can debug or trace a function 'foo' with debug(foo) or trace(foo), > respectively. This leads to a special treatment of the function 'foo' until > one enter undebug(foo) or untrace(foo). I would like to know if there is a > convenient way to know at any time which are the function flagged with > debug() or trace() in a R session.No, there isn't. -thomas -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Philippe Grosjean
2001-Oct-11 14:25 UTC
[R] list of functions flagged with debug() or trace()
>You probably didn't get an answer because the answer is no, there is >no easy way,>-- >+---------------------------------------------------------------------------+>| Robert Gentleman phone : (617) 632-5250|>| Associate Professor fax: (617) 632-2444|>| Department of Biostatistics office: M1B28 >| Harvard School of Public Health email: rgentlem at jimmy.dfci.harvard.edu|>+---------------------------------------------------------------------------+ Thank you. I would like to program it, but I feel it is not easy, because debug() or trace() is not an attribute of the function, at least available through attr()... My approach would be to maintain a list of functions set with debug() or trace(). Does anybody have a better idea? Here is a first draft: Debug <- function(FUN) { if (length(objects(envir=.GlobalEnv, all.names=TRUE, pattern=".debug.functions")) != 0) .debug.functions <- get(".debug.functions", envir=.GlobalEnv) else .debug.functions <- NULL assign(".debug.functions", unique(c(.debug.functions, deparse(substitute(FUN)))), env= .GlobalEnv) debug(FUN) } Undebug <- function(FUN) { if (length(objects(envir=.GlobalEnv, all.names=TRUE, pattern=".debug.functions")) != 0) .debug.functions <- get(".debug.functions", envir=.GlobalEnv) else .debug.functions <- NULL pos <- which(.debug.functions == deparse(substitute(FUN))) if (length(pos) > 0) assign(".debug.functions", .debug.functions[-pos], env= .GlobalEnv) undebug(FUN) } Trace <- function(FUN) { if (length(objects(envir=.GlobalEnv, all.names=TRUE, pattern=".trace.functions")) != 0) .debug.functions <- get(".trace.functions", envir=.GlobalEnv) else .debug.functions <- NULL assign(".trace.functions", unique(c(.debug.functions, deparse(substitute(FUN)))), env= .GlobalEnv) trace(FUN) } Untrace <- function(FUN) { if (length(objects(envir=.GlobalEnv, all.names=TRUE, pattern=".trace.functions")) != 0) .debug.functions <- get(".trace.functions", envir=.GlobalEnv) else .debug.functions <- NULL pos <- which(.debug.functions == deparse(substitute(FUN))) if (length(pos) > 0) assign(".trace.functions", .debug.functions[-pos], env= .GlobalEnv) undebug(FUN) } Of course, I should better mask debug/undebug and trace/untrace instead of using Debug/Undebug Trace/Untrace, but then, how do I call the original debug/undebug, trace/untrace primitives in the body of my function? Thanks for help, Philippe Grosjean ...........]<(({?<...............<?}))><............................... ) ) ) ) ) __ __ ( ( ( ( ( |__) | _ ) ) ) ) ) | hilippe |__)rosjean ( ( ( ( ( Marine Biol. Lab., ULB, Belgium ) ) ) ) ) __ ( ( ( ( ( |\ /| |__) ) ) ) ) ) | \/ |ariculture & |__)iostatistics ( ( ( ( ( ) ) ) ) ) e-mail: phgrosje at ulb.ac.be or phgrosjean at sciviews.org ( ( ( ( ( SciViews project coordinator (http://www.sciviews.org) ) ) ) ) ) tel: 00-32-2-650.29.70 (lab), 00-32-2-673.31.33 (home) ( ( ( ( ( ) ) ) ) ) "I'm 100% confident that p is between 0 and 1" ( ( ( ( ( L. Gonick & W. Smith (1993) ) ) ) ) ) ....................................................................... -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._