On Wed, 21 Apr 2004 00:47:55 +0000 (UTC), Gabor Grothendieck
<[EMAIL PROTECTED]> wrote:


>Thanks.  Your hypothesis does seem likely.  In
>
>g <- f; environment(g) <- new.env()
>
>is there any way that I can automatically set g to have debugging 
>iff f has it?

undebug() gives a warning if the function doesn't have the debug flag
set, so it's possible to do it.  I'm new to the new signals in R, so
this might be a really ugly implementation, but here goes:

isbeingdebugged <- function(f) {
    if (is.function(f)) {
        result <- tryCatch(undebug(f), warning = function(w) 1)
          result <- is.null(result)
          if (result) debug(f)
          result
    } else stop('Not a function')
}

copydebugstatus <- function(f, g) {
   if (isbeingdebugged(f)) debug(g)
   else if (isbeingdebugged(g)) undebug(g)
}

Duncan Murdoch

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to