PLC Flashcards
What does the process of allocation to a variable do?
To allocate a variable is to bind an address to it
What does it mean if the process of allocation is done dynamically
If allocation is done dynamically then it is done during the runtime
What does it mean if the process of allocation is done statically
If allocation is done statically then it is done during initialisation time
What are the 6 attributes of variables
Name
Address (aka L-Value)
Value (aka R-Value)
Type
Extent
Scope
What are the two types of binding
What do they each mean
Static and Dynamic
Static binding means that variables are bound during compile time and do not change during execution
Dynamic binding means they either: are bound for the first time at runtime or a binding changes during runtime
What is the extent of a variable
The extent is the time between allocation and deallocation
What are the four kinds of variables
Static Variables
Stack dynamic variables
Explicit heap dynamic variables
Implicit heap dynamic variables
Explain what Static Variables are
Also known as global variables these are bound to a memory at initialisation time. An example of these are static class variables in Java
Explain what Stack Dynamic Variables are
Also known as local variables the memory for these is allocated from the runtime stack when some declaration, i.e. a method, is executed. These are deallocated when that procedural block they are used in returns. An example of a stack dynamic variable is the local variables in a method declaration
Explain what Explicit heap dynamic Variables are
These are nameless, abstract memory locations which can be allocated and deallocated by the programmer using explicit command such as malloc
in C or new
in Java
Explain what Implicit Heap Dynamic Variables are
These are an error prone and inefficient form of variable which memory is allocated to when the variables are assigned to values, it is deallocated and reallocated when the variable is redefined
What are the two types of type binding?
Static type and dynamic type binding
What are the two types of static type binding
Type declaration and type inference
What is static type, type declaration, binding
Then name when variables are introduced with an explicit type (and possibly value)
What is static type, type inference, binding
Then name for when variables types are worked out from usage of the variable or by following a fixed naming scheme