Terminology Flashcards
(41 cards)
Static memory allocation
Memory is allocated at compile time
Static typing
Type checking is done at compile time. It is not necessary to define an object before it is used but you must have an explicit type declaration e.g. int num; num = 10; (C/C++, Java)
Dynamic typing
Type checking is done at run time. All variables must be defined before they are used. e.g. num = 10; (Python)
Aliasing
When two names or expressions refer to the same location e.g. no array bounds checking in C; “shallow” object copies
Formal parameters
The parameter names used in a function declaration
Actual parameters
When a function is called expressions called actual parameters are used to compute the parameter values for that call
Expressions
Syntactic entity that may be evaluated to determine its value
Statement
Command that alters the state of the machine in some explicit way
Declaration
Syntactic entity that introduces a new identifier
Static scope
Identifier refers to the declaration of that name that is declared in the closest enclosing scope of the program text e.g. const int b = 5; int foo() { int a = b + 5; return a; }
int bar() { int b = 2; return foo(); }
int main() { foo(); // returns 10 bar(); // returns 10 return 0; }
Dynamic scope
Global identifier refers to the declaration associated with the most recent environment e.g. const int b = 5; int foo() { int a = b + 5; return a; }
int bar() { int b = 2; return foo(); }
int main() { foo(); // returns 10 bar(); // returns 7 return 0; }
Abstract/virtual machine
An idealised device that can execute a programming language directly
Garbage collection
The process of detecting garbage (memory locations that are not available to the program) during the execution of a program and making it available
Call by value
Evaluate the expressions in the actual parameter list and pass the resulting values
Call by text
Transmit the expression in the actual parameter list as text so that the called function can evaluate them as needed using “eval”
L-value
Location of a variable
R-value
Value of a variable
Call by reference
The L-value (address) of the actual parameter is bound to the formal parameter. The formal parameter becomes a synonym for the location of the actual parameter.
Call by value/result or copy-in/copy-out
The actuals are copied into the formals and on return the formals are copied back to the actuals
Call by name
Actual parameters are re-evaluated every time the formal parameter is used (evaluated in the scope of the caller). Similar to beta reduction
Dynamic lookup
When a method of an object is called, the method body to be executed is selected dynamically at run time according to the implementation of the object that receives the message (e.g. C++ virtual methods)
Abstraction
Implementation details are hidden inside a program unit with a specific interface e.g. a set of methods that manipulate hidden data
Subtyping
A relation on types that allows values of one type to be used in place of values of another
Substitutivity
If A is a subtype of B then any expression of type A may be used without type error in ay context that requires an expression of type B