Skip to content
Prev 24481 / 63424 Next

Exchange of information between functions aside from argument/return-value interface

On Wed, 4 Apr 2007, Peter Ruckdeschel wrote:

            
I think you did. You seem to be thinking in terms of dynamic scope,
which looks for variables in the caller and then the caller's caller.

Lexical scope addresses exactly this problem.  In lexical scope
variable references are resolved on the basis of how function
definitions are nested in the written code (hence the term lexical).
If you define myH inside myF then free variables in myH are looked up
first in myF and then in the context where myF is defined. How myH is
called does not matter.  Nested functions in Pascal work the same way
if that helps.

[In terms of the internal implementation, the enclosing environment of
the environment of myH is the frame of the call to myF that created
myH.]

Best,

luke


THis is exactly the pro