1/9
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
Var attrs - Name
not all variables have them
Var attrs - Address
the memory address with which it is
associated
– A variable may have different addresses at different
times during execution
– A variable may have different addresses at different
places in a program
– If two variable names can be used to access the same
memory location, they are called aliases
– Aliases are created via pointers, reference variables, C
and C++ unions
– Aliases are harmful to readability (program
readers must remember all of them)
Var attrs - Type
determines the range of values of
variables and the set of operations that are
defined for values of that type; in the case of
floating point, type also determines the precision
var attrs - Value
the contents of the location with which
the variable is associated
- The l-value of a variable is its address
- The r-value of a variable is its value
Abstract memory cell
the physical cell or
collection of cells associated with a variable
Scope
• The scope of a variable is the range of statements
over which it is visible
• The local variables of a program unit are those that
are declared in that unit
• The nonlocal variables of a program unit are those
that are visible in the unit but not declared there
• Global variables are a special category of nonlocal
variables
• The scope rules of a language determine how
references to names are associated with variables
Subscript Binding and Array Categories - Static
subscript ranges are statically
bound and storage allocation is static
(before run-time)
– Advantage: efficiency (no dynamic allocation)
Subscript Binding and Array Categories - Fixed stack-dynamic
subscript ranges are
statically bound, but the allocation is done
at declaration time
– Advantage: space efficiency
Subscript Binding and Array Categories - Fixed heap-dynamic
similar to fixed
stack-dynamic: storage binding is
dynamic but fixed after allocation (i.e.,
binding is done when requested and
storage is allocated from heap, not stack)
Subscript Binding and Array Categories - Heap-dynamic
binding of subscript
ranges and storage allocation is dynamic
and can change any number of times
– Advantage: flexibility (arrays can grow or
shrink during program execution)