Transcript Bindings

Binding
point when a program element is bound to a characteristic or property
Categories of Binding Times
• Execution Time – during program execution
• binding of variables to values
• binding of variables to their locations (e.g., automatics in C)
• binding of parameters to arguments
• on function entry for by value and by address parameters
• on reference for by name parameters
• Translation Time (compile time) - bindings performed by the compiler
• binding of variables to their data types (C)
• binding of variables to their structure (C)
• binding of variables to their locations (static in C, but the actual address is
bound by the loader)
Categories of Binding Times
• Language Definition Time - when the language was described
• meaning of +, -, *, /
• meaning of if, printf
• Language Implementation Time - variations for a particular
implementation of the language
• ordering of bits (little endian, big endian)
• size of int, size of long
• meaning of isalpha in C
Importance of Binding Times
• Changing of binding times can modify the definition of
a language
• Suppose we bind all variables to their locations at
compile/load time, how would that impact a language?
• No by address parameter passing
• No dynamic arrays (where the size is defined at runtime)
• No recursion
Importance of Binding Times
• Later binding times can decrease the speed of code
execution
• If data types are bound at runtime:
• Less error detection available during translation
• Arithmetic operations would require checking the datatypes of operands, slowing
execution
Importance of Binding Times
• Later binding times can increase the flexibility of a
language
• Binding the size of an array at runtime:
• We can allocate the size we actually need instead of an arbitrary large
amount
• Allocating memory at runtime:
• We can allow a data structure (e.g., linked list) to grow
• We can share heap memory with multiple data structures
• Statements translated at runtime:
• We could more easily modify code during execution
• Data could act as program statements
What happens when?
In C, “what happens when” for the following statement:
iX = iY + 5;
Execution:
• Value of iX and iY
Translation:
• data types for iX and iY
• data type of + result and = result
Language Def:
• data type of 5
• meaning of +
• meaning of =
Language Imp:
• representation of 5
• representation of result of iY + 5
Unknown (due to example):
• Location of iX and iY