PLC Flashcards
Learn PLC
In terms of variables, what is aliasing
Aliasing is the name given when two variables point to the same location in memory, it is something we aim to avoid
What are the 6 attributes of variables
+ Name
+ Address (L-Value)
+ Value (R-Value)
+ Type
+ Extent
+ Scope
What does the “Extent” of a variable refer to?
The extent of a variable is also known as the lifetime
It refers to the amount of time in the programs execution in which the variable will be assigned a meaningful value
What is a binding
Binding is the name given to associating attributes with variables. i.e.
+ Binding type
+ Binding address
+ Binding scope
What are the two types of binding and what is the difference
Static Binding - Where variables are bound during compile time and do not change during execution
Dynamic binding - Where variables are bound for the first time during execution OR when the binding can change during runtime
What is the name given to the process of binding a variable to its address
Allocation
What process does Deallocation refer to
Deallocation refers to the process of unbinding a variable from an address
This is largely dynamic as it cannot be done at compile time
What is the difference between static allocation and dynamic allocation
Static allocation refers to binding an address to a variable at compile time
Dynamic allocation refers to binding an address to a variable at runtime
What are the four kinds of variables
+ Static Variables
+ Stack Dynamic Variables
+ Explicit Heap Dynamic Variables
+ Implicit Head Dynamic Variables
What is a Static Variable
Static variables are bound to memory at initialisation time, and are also known as global variables.
In Java these are referred to by their class
What is a
Stack Dynamic Variable
Stack Dynamic Variables are allocated when some declaration is executed, they are then deallocated when that procedural block returns
What “kind” of variables are local variables
Stack Dynamic variables
What is an Explicit Heap Dynamic Variable
These are nameless, abstract memory locations. They are allocated and deallocated explicitly by the programmer with commands such as malloc
or new
What is an Implicit Heap Dynamic Variable
This is a form of variable where memory is allocated from the heap when the variable is assigned to a value.
They are deallocated and reallocated when the need to be re-assigned
What is static type binding
Static type binding is the name given when a variable is assigned a type at compile time
What is Dynamic type binding
Dynamic type binding occurs when the variable is assigned a type at runtime
It is commonly used in scripting languages
What are the two types of static type binding
+ Type Declaration - this is the most common approach and is where the variable is given an explicit type when its introduced
+ Type Inference - this approach does not require explicit typing, instead, it works out the type from the usage of the variable or from following naming conventions
What is the extent of a Static variable
The whole program
What is the extent of Stack Dynamic Variables
A particular stack frame or procedure call
What is the extent of Explicit heap dynamic variables
Explicit allocation to explicit deallocation (malloc
to free
)
What is the extent of Implicit Heap Dynamic Variables
Implicit allocation to implicit deallocation, meaning variables may persist in memory even once the addresses have been freed
What does Lexical Scope refer to
Lexical Scope is refers to when the scope of variables is aligned to statically determined areas of the code file such as class definitions or the method body
What does Dynamic Scope refer to
Dynamic scope is determined at runtime by control flow, variables are only made to be meaningful within the context of the current call stack, aka when its been used before.
What is a recursive descent parser
Recursive decent parse build parse trees from the root down, this makes them good for LL Grammars, as it reads Left to Right and forms Leftmost derivations