I'm programming for a long time (actually very long), but I really want to get a handle I'm fighting on the words "Free Variables" and "Bound Variable"
I started the "explanation" online by talking about topics like "Lavanda Calculus and formal reasoning, or self-governing semantics, which I want to do.
Can understand the conditions, ideally from the perspective of implementation. Can they be present in compiled languages and what lower-level code do they translate?
A free variable is a function Which is used in some functions, its value depends on the context where the function is invoked , which is called or used, for example, math z is an independent variable because it is not surrounded by any parameter. x
is an bound variable :
f (x) = x * z
, a free variable dynamic Time determined And the variable name is determined by searching for the name of the back.
A bounded variable evaluation function does not depend on the context of the call It is the most common modern programming language variable type . Local variables, global variables and parameters are all bound variables.
A Free Variables is similar to the conference of some ancient programming languages.
Assume that you have a function f
which prints some variable:
def f (): print (x) < / Code>
This is the Python while X
is not a local variable, its value follows the Python Conference: it searches the top of the block where the function is defined Is done until it reaches the top level module.
Since the value of X
in the Python is defined by the declaration reference, we say that X
is a bound variable.
Hypothetically, if X
were a free variable, then this 10:
X = 2 def f (): print (X ) Def g () should be printed: # X is a local variable covering the Global XX = 10F ()
, in Python, this code prints 2 because both < Code> X variables are restricted. The local X
variable on g
is surrounded as a local variable, and a global X
on f
.
Implementation
The implementation of a programming language with free variables should be kept in mind where each function is called, and for every free variable, use some search To do the variable
The value of a free variable can not be generally set at compilation, because run time is determined heavily by flow and call stack.
Comments
Post a Comment