whoami <- function() {
	if (sys.parent() == 0)
		"<GlobalEnv>"
	else
		as.character(sys.call(-1)[[1]])	
}

whoami()

f <- function() {
	x <- whoami()
	cat("My name is", x, "\n")
}

f()

"James Bond" <- f
rm(f)
"James Bond"()
