Session {methods} | R Documentation

## Session Data and Debugging Tools

### Description

The function `sessionData` provides a work-around in R for the absence of a session database (what you get in S with the argument `where=0` to functions such as `get` and `assign`).

The functions `traceOn`, `traceOff` and `browseAll` are debugging tools with roughly similar functionality to `trace`, `untrace` and `browser` as described in the reference. Calling `traceOn` creates a new version of a function with arbitrary code inserted at the beginning of the call and/or on exit. Calling `traceOff` undoes the change. The function `browseAll` is a useful interactive call to insert for tracing. It behaves basically like `debugger`.

Note: use `traceOn` only for testing functions in a library, not for functions defined in the global environment. Because the session data is in position 2 on the search list, the temporary versions stored there will not override functions in the global environment.

A more satisfactory version of these facilities is likely to be provided in the future. Use the current versions but don't write code that depends on them.

### Usage

    sessionData()

    traceOn(what, tracer=browseAll, exit=NULL)

    traceOff(what)

    browseAll()

### Arguments

`what` | The object to be traced or untraced.
`tracer, exit` | The code to use at the entrance or exit trace. Either a function (which will be called with no arguments) or an expression (typically constructed from `link{quote}` or `substitute`) to be evaluated.

### Details

`sessionData`: return the index of the session data in the search list, attaching it if it is not attached

`traceOn`: initialize tracing on calls to function `what`. The function or expression `tracer` is called on entry, and the function or expression `exit` on exit.

`traceOff`: turn off tracing of this function

`browseAll`: browse the current stack of function calls.

Uses the function `debugger` to set up browser calls on the frames. On exit from that function, computation continues after the call to browseAll. Computations done in the frames will have no effect.

### Author(s)

John Chambers

### References

See Programming with Data (John M. Chambers, Springer, 1998) for the equivalent functions.

[Package Contents]