Chapter 5: Names, Bindings, and Scopes

5.3: Variables
int varName = varValue

Value

That which is stored within a variables memory. placed on the RHS of a declaration or assignment.

Name

Names are the way that we identify variables. Immediately after type (varName in this case)

Aliases

One address can be referenced by two names, not good for
reading code

Address

Addresses are the computer memory cells that store information in them regarding the variable. This is not seen directly by programmers.

Type

The type of information stored, this in part determines the amount of memory and how that information is stored. A long int will take up more space than a short or regular int. (The type in this case is int, it precedes the variable name. In some cases it is not needed)

5.6: Scope and Lifetime of Variables

Scope is the "reach" that a variable has, where it may be accessed.

Often restricted to the function range

Scope is where the function can be reached,
Lifetime is temporal and is the time that the memory for that variable exists and is allocated

C++'s 'static' keyword extends lifetime beyond the life of the function, but doesn't alter scope.

Both of these concepts become fuzzy with subprogram calls and in a number of other situations outside of function calls from main.