Description Usage Arguments Details Value Author(s) See Also Examples
These functions are "do what I mean, not what I say" equivalents of the corresponding system functions. The system functions can behave strangely when called in strange ways (primarily inside eval
calls). The mvb
equivalents behave in a more predictable fashion.
1 2 3 4 5 6 7 8 9 | mvb.sys.parent(n=1)
mvb.sys.nframe()
mvb.parent.frame(n=1)
mvb.eval.parent( expr, n=1)
mvb.match.call(definition = sys.function(mvb.sys.parent()),
call = sys.call(mvb.sys.parent()), expand.dots = TRUE, envir= mvb.parent.frame( 2))
mvb.nargs()
mvb.sys.call(which = 0)
mvb.sys.function(n)
|
All as per the corresponding system functions, from whole helpfiles the following is taken:
which |
the frame number if non-negative, the number of generations to go back if negative. (See the Details section.) |
n |
the number of frame generations to go back. |
definition |
a function, by default the function from which |
call |
an unevaluated call to the function specified by |
expr |
an expression to evaluate |
expand.dots |
logical. Should arguments matching |
envir |
an environment from which the ... in call are retrieved, if any (as per |
Sometimes eval
is used to execute statements in another frame. If such statements include calls to the system versions of these routines, the results will probably not be what you want. In technical terms: the same environment will actually appear several times on the call stack (returned by sys.frame()
) but with a different calling history each time. The mvb.
equivalents look through sys.frames()
for the first frame whose environment is identical to the environment they were called from, and base all conclusions on that first frame. To see how in detail, look at the most fundamental function: mvb.sys.parent
.
mvbutils
pre 2.7 used to include mvb.sys.on.exit
as well (to return whatever the on.exit
code would be), but I think this was by mistake; the code was actually specific to my debug
package (which already has its own substitute), and so I've moved it out of mvbutils
.
See the helpfiles for the system functions.
Mark Bravington
sys.parent
, sys.nframe
, parent.frame
, eval.parent
, match.call
, nargs
, sys.call
, sys.function
1 2 3 4 5 6 7 8 9 10 11 12 | ff.no.eval <- function() sys.nframe()
ff.no.eval() # 1
ff.system <- function() eval( quote( sys.nframe()), envir=sys.frame( sys.nframe()))
ff.system() # expect 1 as per ff.no.eval, get 3
ff.mvb <- function() eval( quote( mvb.sys.nframe()), envir=sys.frame( sys.nframe()))
ff.mvb() # 1
ff.no.eval <- function(...) sys.call()
ff.no.eval( 27, b=4) # ff.no.eval( 27, b=4)
ff.system <- function(...) eval( quote( sys.call()), envir=sys.frame( sys.nframe()))
ff.system( 27, b=4) # eval( expr, envir, enclos) !!!
ff.mvb <- function(...) eval( quote( mvb.sys.call()), envir=sys.frame( sys.nframe()))
ff.mvb( 27, b=4) # ff.mvb( 27, b=4)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.