Hi Antoine,
ok, I thought you were reporting that
> foo <- function() "hello"
> trace2 <- function(fun) trace(fun, quote(print("!!!")))
> trace2(foo)
> base::fun
in error did not trace "foo" in the top-level environment. This is,
however, expected, because "trace" is called with argument fu
Hi Tomas,
The doc indeed describes `what` as "the name, possibly quote()d, of a
function to be traced or untraced".
This is a good argument not to change the function and make it behave more
like debug.
However the doc also tells us "A call to trace allows you to insert
debugging code (e.g., a ca
Please note that this is documented in ?trace. "fun" is matched to what,
it is a _name_ of the function to be traced, which is traced in the
top-level environment. I don't know why it was designed this way, but it
is documented in detail, and hence the expected behavior.
Debugging is often, an
Apologies there is one line missing in my last email, the code should be :
foo <- function() "hello"
trace2 <- function(fun) trace(fun, quote(print("!!!")))
trace2(foo) # <- THIS LINE WAS MISSING
base::fun
Best,
Antoine
Le mar. 25 août 2020 à 22:02, Antoine Fabri a
écrit :
> Dear R-devel,
>
>
Dear R-devel,
I don't think this is expected :
foo <- function() "hello"
trace2 <- function(fun) trace(fun, quote(print("!!!")))
base::fun
# Object with tracing code, class "functionWithTrace"
# Original definition:
# function() "hello"
#
# ## (to see the tracing code, look at body(object))
`unt