browser.default(object=<<see below>>, catch=T, parent=<<see below>>, message=NULL, prompt="b> ", readonly=F, verbose=F, ...)
browser
.
Therefore in its usual use,
adding the expression browser()
to a function allows you to see what the function has done so far.
TRUE
, then the browser will be restarted after such errors.
(However, see the quit signal comment below.)
If
FALSE
,
any errors will cause a return to the S-PLUS prompt level.
sys.parent(1)
if
object
is present
and
sys.parent(2)
if it is not.
FALSE
and if
frame
is missing or numeric,
assignments will cause changes in the corresponding evaluation frame
that persist after the return from
browser.default
.
TRUE
,
the browser prints much more text to the screen in response to browser actions.
return
expression
typed by the user.
If you return by giving a response
0
to the prompt,
the value is
NULL
.
readonly
is
FALSE
and
frame
is missing or numeric.
When the browser is invoked, you will be prompted for input.
The input can be any expression;
this will be evaluated in
frame
.
Three kinds of expressions are special.
The response
?
will get you a list of commands available in the browser:
navigate between frames.
return
expression returns
from the browser with this value.
browser
is called
without an explicit frame argument,
as in the example,
assignments take place in the calling function's frame.
Thus,
browser
can be used to try out
revisions in real time,
without editing the function.
A similar use can be made of the case of an explicit frame;
assignments change the frame, as it appears inside
browser
,
so that modifications in the situation as captured
in
frame
(for example, through
dump.frames
and
debugger
)
can be tried out interactively.
Both these versions can be helpful in software design and debugging.
browser
.
up
,
down
,
stop
,
where
,
and
q
are implemented using the auxiliary functions
upBrowser
,
downBrowser
,
stopBrowser
,
whereBrowser
,
and
qBrowser
, respectively.
If the function you are browsing has arguments matching these command names,
you can perform the desired action by calling the associated
*Browser
function directly.
For example,
qBrowser()
will
quit the browser and return you to the S-PLUS prompt.
trace(foo, browser) # call browser on entering foo options(interrupt=browser) myfun <- function(x,y) { # lots of computing browser() # now check things just before the moment of truth .C("myroutine",x,y,w) }