sys.call
Get the System Evaluator State

### Description

Returns information from the evaluator stack.

### Usage

    sys.call(which = 0)
    sys.frame(which = 0)
    sys.nframe()
    sys.function(which = 0)
    sys.parent(n = 1)
    parent.frame(n = 1)
    sys.calls()
    sys.frames()
    sys.parents()
    sys.on.exit()
    sys.status()

### Arguments

which | the stack frame number if strictly positive; the current frame if zero. Otherwise, the number of stack frames to go back.
n | the number of stack frames to go back.

### Details

All of these functions return various objects describing the current state of the evaluator in terms analogous to the model described in chapter 11 of Becker, Chambers and Wilks. The first six functions describe a particular stack frame: by the default, the current frame (for example, the function call from which sys.call was called). Most of the remaining functions describe the list of all stack frames.
Value

sys.call | returns the actual call for the frame specified by which. By default, which is the stack frame in which the call to sys.call is made.
sys.frame | returns the local environment in the stack frame specified by which. By default, sys.frame returns the global environment.
sys.nframe | returns the numerical index of the current stack frame in the stack.
sys.function | returns the definition of the function being called in the stack frame n (by default, the current stack frame).
sys.parent | returns the index in the list of stack frames of the parent (that is, the caller) of the current function. The argument to sys.parent specifies how many steps to go back in the call chain. (By default, it goes to the caller of the caller of sys.parent).
parent.frame | returns the environment of the parent (that is, the caller) of the current function. The argument to parent.frame specifies how many steps to go back in the call chain. (By default, it goes back to the caller of the caller of parent.frame).

All stack frames:

sys.calls | returns the list of the function calls that generated the frames.
sys.frames | returns a list with the local environments for the stack frames.
sys.parents | returns the indices of the parent frames for each of the frames.
sys.on.exit | returns the list of expressions given to on.exit and currently still scheduled to be evaluated on exit from the corresponding frame.
sys.status | returns the complete internal evaluator status; that is, everything above.

References
Becker, R.A., Chambers, J.M., and Wilks, A.R. (1988) The New S Language. Wadsworth and Brooks/Cole. Pacific Grove, CA.
Note

- Both sys.call and match.call return an object of class call; however, sys.call returns the actual call (with argument names missing or abbreviated), and match.call returns the call for which the arguments are specified by name. Use match.call when you create a call component or attribute.

- If the caller of the current function is not on the call stack, then sys.parent returns 0 and parent.frame returns the global environment.

- sys.frame interprets which differently from the other functions. sys.frame(0) returns the global envionment, not the current environment.

- The result of these functions are based on the call stack seen by the function that calls them. Due to lazy evaluation, some stack frames might be hidden. The exception is sys.on.exit, which sees all stack frames.

See Also
frame.attr, match.call
Examples

    myplot <- function(x, y)
    {
            the.call <- sys.call()
            xname <- deparse(the.call[[2]])
            yname <- deparse(the.call[[3]])
            plot(x, y, xlab = xname, ylab = yname)
            return(list(call = the.call))
    }

Package base version 6.1.5-18
Package Index