###--- >>> `sys.parent' <<<----- Functions to Access the Function Call Stack

	## alias	 help(sys.parent)
	## alias	 help(sys.call)
	## alias	 help(sys.calls)
	## alias	 help(sys.frame)
	## alias	 help(sys.frames)
	## alias	 help(sys.nframe)
	## alias	 help(sys.function)
	## alias	 help(sys.parents)
	## alias	 help(sys.on.exit)
	## alias	 help(sys.status)
	## alias	 help(parent.frame)

##___ Examples ___:

ff <- function(x) gg(x)
gg <- function(y) sys.status()
str(ff(1))

gg <- function(y) {
    ggg <- function() {
        cat("current frame is", sys.nframe(), "\n")
        cat("parents are", sys.parents(), "\n")
        print(sys.function(0)) # ggg
        print(sys.function(2)) # gg
    }
    if(y > 0) gg(y-1) else ggg()
}
gg(3)

t1 <- function() {
  aa <- "here"
  t2 <- function() {
    ## in frame 2 here
    cat("current frame is", sys.nframe(), "\n")
    str(sys.calls()) ## list with two components t1() and t2()
    cat("parents are frame nos", sys.parents(), "\n") ## 0 1
    print(ls(envir=sys.frame(-1))) ## [1] "aa" "t2"
    invisible()
  }
  t2()
}
t1()

test.sys.on.exit <- function() {
  on.exit(print(1))
  ex <- sys.on.exit()
  str(ex)
  cat("exiting...\n")
}
test.sys.on.exit()
## gives `language print(1)', prints 1 on exit

## Keywords: 'programming', 'data'.


