A binding/constraint (binding) refers to an association between two things. As the name and the thing it stands for. Also, an association between an attribute and an entity, or between a symbol and an action.
The early books were translated into constraints, the late majority was called binding. Subsequent is called binding.
The time the binding occurs is called the binding time (binding times).
Binding and binding time is a very important concept in the programming language.
Bindings can occur at the language design time, language implementation, compile-time, connection, load, and run time.
A. Language design time
In most languages, operators, process control structures, internal types, and the construction of objects are all determined at the language design time.
such as the asterisk (*) are bound to the multiplication operation at language design time.
Second, when the language is implemented
Most language manuals leave many questions, requiring language learners to think carefully and decide how to implement them.
such as the precision of the base type (range of values), the int in C is bound to the value range when implemented.
Also such as stack and heap to block the way and maximum size.
Third, compile-time
The compiler has chosen how to map the advanced structure to machine code, including how statically defined data is laid out in memory.
Variables such as Java are bound to a specific data type at compile time.
Four, when connecting
Most compilers support "compile separately", the connector chooses the overall layout according to each module, and solves the cross module mutual reference relationship. You need to assemble the different modules together by the connector.
V. Load-ins
The moment the operating system loads the program into memory to enable it to execute.
If the Java program is loaded, the variable is bound to a storage unit.
Six, run time
This is a broad concept that overrides the time span from the beginning to the end of the execution of the program.
Occurs when the binding of a variable and a value is run. However, many other decision-making matters vary according to language. The
bindings are divided into static bindings and dynamic bindings.
Static binding/early binding refers to a binding that was established before running and remains unchanged throughout the execution of the program.
Dynamic binding/Late binding refers to the bindings that are established during the run and can be changed during execution.
Of course, both static and dynamic are very rough statements. Because the concept of the runtime itself is very broad, not strict. The
Pure-compilation language (static language) is naturally early bound. They are more efficient because they make decisions earlier. The
compiler makes an analysis of the syntax semantics of global variables only once, that is, before the program is run. At that time, the layout of these variables in memory was determined and the efficient code to ask them was generated.
Pure interpreted language (Dynamic language), which is naturally late-bound. They are more flexible because they postpone many decisions until they are run. corresponding to its low efficiency.
It may parse some declarations at every run, and even the interpreter will parse local variables every time the subroutine calls.