Chapter 5 Flashcards
Names, Bindings & Scopes
___ ___ in programming languages are used to make programs more readable by naming actions to be performed.
Special words
A ___ ___ is a special word of a programming language that cannot be used as a name.
Reserved word
A program ___ is an abstraction of a computer memory cell or collection of cells.
variable
A variable is characterized by 6 attributes. What are they?
Name Address Value Type Lifetime Scope
The address of a variable is the ___ ___ address with which it is associated.
machine memory
When more than one variable name can be used to access the same memory location, the variables are called ___.
Aliases
The ___ of a variable determines the range of values the variable can store and the set of operations that are defined for values of the that ___.
Type
The ___ of a variable is the contents of the memory cell or cells associated with the variable
value
a variable’s value is sometimes called its ___ because it is what is required when the name of the variable appears in the right side of an assignment statement.
r-value
A ___ is an association between an attribute and an entity, such as between a variable and its type or value, or between an operation and a symbol.
binding
The time in which the associations with a variable are made are called its ___ time.
binding
IN: count = count + 5;
The type of count is bound at ___ time.
compile
IN: count = count + 5;
The set of possible values of count is bound at ___ ___ time.
compiler design
IN: count = count + 5;
The meaning of the operator symbol + is bound at ___ time, when the types of its operands have been determined.
compile
IN: count = count + 5;
The internal representation of the literal 5 is bound at ___ ___ time
compiler design
IN: count = count + 5;
The value of count is bound at ___ time with this statement.
execution
A binding is ___ if it first occurs before run time begins and remains unchanged through program execution.
static
If the binding first occurs during run time or can change in the course of program execution, it is called ___
dynamic
An ___ ___ is a statement in a program that lists variable names and specifies that they are a particular type.
explicit declaration
An ___ ___ is a means of associating variables with types through default conventions, rather than declaration statements.
implicit declaration
The memory cell to which a variable is bound somehow must be taken from a pool of available memory; this process is called ___
allocation
___ is the process of placing a memory cell that has been unbound from a variable back into the pool of available memory.
Deallocation
The ___ of a variable is the time during which the variable is bound to a specific memory location.
lifetime
A ___ ___ is one that is bound to a memory cell before program execution begins and remains bound to that same memory cell until program execution terminates.
static variable
___-___ variables are those whose storage binding are created when their declaration statements are elaborated, but whose types are statically bound.
stack-dynamic
___ refers to the storage allocation and binding process indicated by the variable’s declaration, which takes place when execution reaches the code to which the declaration is attached.
Elaboration
An advantage of __ variables is efficiency; addressing can be direct and no run-time overhead is incurred for allocation and deallocation.
static
A disadvantage of ___ binding is reduced flexibility; a language that has only static variables cannot support recursive subprograms.
static binding
An advantage of ___-___ variables is it allows for recursive subprograms by creating dynamic local storage for each active copy of the local variable.
stack-dynamic
A disadvantage of ___-___ is the overhead required for allocation and deallocation.
stack-dynamic
___ ___-___ variables are nameless (abstract) memory cells that are allocated and deallocated by explicit run-time instructions written by the programmer.
explicit heap-dynamic
The ___ is a collection of storage cells whose organization is highly disorganized due to the unpredictability of its use.
heap
___ ___-___ variables are often used to construct dynamic structures, such as linked lists and tress, that need to grow and/or shrink during execution.
Explicit heap-dynamic
The disadvantages of ___ ___-___ variables are the difficulty of using pointer and reference variables correctly, the cost of references to the variables and the complexity of the required storage management implementation.
explicit heap-dynamic
___ ___-___ variables are bound to heap storage only when they are assigned values.
Implicit heap-dynamic
The advantage of ___ ___-___ variables is that they have the highest degree of flexibility, allowing highly generic code to be written.
Implicit heap-dynamic
One disadvantage of ___ ___-___ variables is the run-time overhead of maintaining all the dynamic attributes, which could include array subscript types and ranges among others
Implicit heap-dynamic
The ___ of a variable is the range of statements in which the variable is visible.
scope
A variable is ___ in a statement if it can be referenced or assigned in that statement.
visible
___ scoping is when the scope of a variable can be determined prior to execution.
static
___ scoping is based on the calling sequence of subprograms, not on their spatial relationship to each other and can only be determined at run time.
Dynamic
The ___ ___ of a statement is the collection of all variables that are visible in the statement.
referencing environment
A ___ ___ is a variable that is bound to a value only once.
named constant
A binding of a variable to a value at the time it is bound to storage is called ___.
initialization