In R, it is possible to do a 'macro substitution' before executing a piece of code. Using this technique, one can dynamically embed a constant into a function body before actually creating the funciton, avoiding a variable look-up:
expr = substitute(function () s, list('s'='ABCDE'))
f = eval(expr)
f()
# [1] "ABCDE"
environment(f)
# <environment: R_GlobalEnv>
Here, the enclosing environment is R_GlobalEnv, which does not contain the variable s at all, but the function can still return "ABCDE" correctly. This seems to mean that the returned string "ABCDE" was indeed not from a variable lookup, but is embedded into the function body.
But now if you print the function, you can see that s is still there, although it is not in expr:
print(f)
# function () s
print(expr)
# function() "ABCDE"
What exactly is going on here?