Part 1 Flashcards
(24 cards)
Static Variable
Bound to memory cells before execution, begins and remains bound to the same memory cell throughout execution
Stack Dynamic
Storage bindings are created for variables when their declaration statements are elaborated
Explicit heap-Dynamic
Allocated and Deallocated by explicit directive, specified by the programmer, which take effect during execution
Implicit heap-Dynamic
Allocation and deallocation caused by assignment statements
Scope of a variable
Range of statements over which it is visible (can be referenced, used, or accessed)
Local Variables
Those that are declared in that unit
Nonlocal variables
those that are visible in the unit but not declared there
Global Variables
Special category of nonlocal variables
Scope rules
Determine how references to names are associated with variables
Lifetime of a Variable
The time during which it is bound to a particular memory cell
Static Scope
Known at compile time. Based on the physical structure of the program
Dynamic Scope
Determined at run time based on the calling sequence
Static Scope Search
First Locally, then in increasingly larger enclosing scopes, until one is found for the given name
Static Ancestors
Enclosing static scopes to a specific scope
Static Parent
Nearest static ancestor
Diff between Lifetime and Scope
Lifetime is the entire code, Scope is code that is accessed
Ways of Declaration Order
1) All declarations of variables are at the top of the function and all variables must be declared
2) All variables must be declared but the scope begins at the declaration point and goes through to the end of the block
3) Regardless of where a variable is declared, it’s scope is the entire class
Languages where variables can be declared in For statements
C++, Java, C#
Referencing Environments
The collection of all names that are visible in the statement; in static scope, it is the local variables plus all the visible variables in all of the enclosing scopes
A Subprogram
is active if its execution has begun but has not yet been terminated
Named Constant
Variable that is bound to a value only when it is bound to storage
Type Checking
Activity of ensuring that the operands of an operator are of compatible types
Compatible Type
Either legal for the operator, or is allowed under language rules to be implicitly converted, by compiler-generated code, to a legal type