What is the scope of static method ? What is dynamic scoping law ? I hope you master answers , you can specifically point to the specific point , the best example .
Thank you help ah.
------ Solution ---------------------------------------- ----
not quite understand what you said the landlord noun : static / dynamic scoping method.
static keyword you are going to ask you
------ Solution ---------------------------- ----------------
first you have to understand the concept of so-called " free variables " , that is a function of the non-local variable is not defined function parameters .
From an implementation point of view , the so-called static or dynamic scope, they are "free variable" position is not the same.
dynamic scope to find free variable , a function call activity record is formed along a stack reverse lookup ( of course, this is just a way to realize there are other ways to achieve ) , the so-called "dynamic chain ." Find
static free variables in scope , is to look at the environment in the function definition . To get a static scope, functions can be implemented as a closure ( ie, contains a binary code and define the group environment ) , so much more convenient to find a free variable .
interpreter written in terms of look and achieve static scope more trouble , so many interpreted languages like lisp, perl early are dynamic scope , and now there are some lisp dialect as newlisp, picolisp also dynamic scope.
------ For reference only -------------------------------------- -
Thank you .
没有评论:
发表评论