Topics

Imperative Paradigm Chapter 5 Variables Names Address Types Variables Assignment Binding Lifetime Constants

Chapter 5: Variables 2

Imperative Paradigm Von Neumann Architecture

The most widely used and well-developed programming paradigm. The architecture of the von Neumann Emerged alongside the first computers and machine has a memory, which computer programs in the 1940s. contains both program instructions and Its elements directly mirror the architectural data values, and a processor, which characteristics of most modern computers provides operations for modifying the This chapter discusses the key programming contents of the memory. language features that support the imperative paradigm.

Chapter 5: Variables 3 Chapter 5: Variables 4

Programming Language: Turing Von Neumann Architecture Complete Turing complete: contains integer variables, values, and operations, assignment statements and the control, constructs of statement sequencing, conditionals, and branching statements.

n Other statement forms (while and for loops, case selections, procedure declarations and calls, etc) and data types (strings, floating point values, etc) are provided in modern languages only to enhance the ease of programming various complex applications.

Chapter 5: Variables 5 Chapter 5: Variables 6

1 Imperative Programming Variables Language Turing complete A variable is an abstraction of a memory Also supports a number of additional cell or collection of cells. fundamental features: n Integer variables are very close to the n Data types for real numbers, characters, strings, Booleans and their operands. characteristics of the memory cells:

n Control structures, for and while loops, case (switch) represented as an individual hardware statements. memory word. n Arrays and element assignment. n A 3-D array is less related to the organization n Record structures and element assignment. of the hardware memory: a software mapping n Input and output commands. is needed. n Pointers.

n Procedure and functions. Chapter 5: Variables 7 Chapter 5: Variables 8

Variables: attributes Names

A variable can be thought of as being Names have broader use than simple for completely specified by its 6 basic variables. attributes (6-tuple of attributes). Names or identifiers are used to denote 1. Name: identifier language entities or constructs.

2. Address: memory location(s) n In most languages, variables, procedures and 3. Value: particular value at a moment constants can have names assigned by the

4. Type: range of possible values programmer.

5. Lifetime: when the variable is accessible Not all variables have names:

6. Scope: where in the program it can be n Can have a nameless (anonymous) memory accessed cells.

Chapter 5: Variables 9 Chapter 5: Variables 10

Names Names: length

We discuss all user-defined names here. If too short, they may not convey the meaning of There are some clear design issues to the variable. consider: It too long, the symbol table of the compiler might become too large. n Maximum length? Language examples: n Notation? n FORTAN I: maximum 6 n Are names case sensitive? n COBOL: maximum 30

n Are special words reserved words or n FORTAN 90 and ANSI : maximum 31

keywords? n Ada and Java: no limit and all are significant

n C++: no limit, but implementers often impose one

Chapter 5: Variables 11 Chapter 5: Variables 12

2 Names: notation Names: “standard” notation

Variables can consist of one or more Some standards can be applied to how letters, numbers (as long as a number is variables are named when one word is not the first character), and an underscore used to describe a variable. character (the underline key.) Camel notation ::- { | | ’_’ } n Uses capital letters to indicate the break Some old languages allowed embedded between words. n Camel is named such because the capital spaces which were ignored letters separating the words look like little n FORTRAN 90: camel humps Sum Of Salaries vs. SumOfSalaries n Example: CostOfItemAtSale

Chapter 5: Variables 13 Chapter 5: Variables 14

Names: “standard” notation Names: “standard” notation

Underscore notation Hungarian notation

n Uses an underscore to separate words that n Uses two letters, both lower-case make up a variable. First letter indicates the scope of the variable

n Example: Cost_of_item_at_sale Second letter indicates the type of the variable n Example: l_fCostOfItemAtSale Some other standards are used to identify Prefix notation the data type stored in the variable n Uses a prefix (usually three letters) to indicate the type of variable.

n Example: floCostOtItemAtSale

Chapter 5: Variables 15 Chapter 5: Variables 16

Variable name Explanation Names: case sensitivity I This is a really bad variable to use. You can't tell what it contains and if anyone wants to fix it later, a simple search and replace will be very tedious since single letters are used in words as well. lastname This is much better but uses no form of notation. FOO = Foo = foo ?

LastName This is camel notation Disadvantage: strLastName This is prefix – camel notation. Note that the prefix is in all lower case. Poor readability, since names that look alike last_name This is underscore notation. As with camel notation, you can easily identify the two words to a human are different that make up the variable name Worse in some languages such as Modula-2, str _last_name This is prefix underscore notation. Again, the prefix is in lower case. C++ and Java because predefined names are lcLastName This is Hungarian camel notation. The first two letters tell us what type of variable is mixed case used. In this case, this variable contains a last name, is local to the function/procedure, and is a character string. IndexOutOfBoundsException lc _last_name This is Hungarian underscore notation.

Chapter 5: Variables 17 Chapter 5: Variables 18

3 Names: case sensitivity Names: special words

Advantages: Used to make programs more readable. Larger namespace Used to name actions to be performed. Ability to use case to signify classes of Used to separate the syntactic entities of variables (e.g. make constants be in upper- programs. case) Keyword C, C++, Java, and Modula-2 names are case sensitive but the names in many other n A word that is special only in certain contexts. languages are not. n Example: in FORTRAN the special word Real can be used to declare a variable, but also as Variable in Prolog have to begin with an a variable itself upper case letter.

Chapter 5: Variables 19 Chapter 5: Variables 20

Names: special words Names: special words

n Real TotalSale (variable TotalSale is of type Real) Reserved Word

n Real = 3.1416 (Real is a variable) n A special word that cannot be used as a

n Integer Real (variable Real is of type Integer) user-defined name.

n Real Integer (variable Integer is of type Real) n Example: C’s float can be used to declare a Disadvantage: poor readability variable, but not as a variable itself.

n Distinguish between names and special words by context. Advantage: flexibility

Chapter 5: Variables 21 Chapter 5: Variables 22

Variables: Address Address

The with which a variable is associated. A variable may have different addresses at different times during execution n Also called l-value because that is what is required when a variable appears in the LHS n Example: variable X of a subprogram is of an assignment. allocated from the runtime stack with a A variable (identified by its name) may different address each time the subprogram have different addresses at different is called (e.g. recursion). places in a program n Example: variable X is declared in two different subprograms (functions)

Chapter 5: Variables 23 Chapter 5: Variables 24

4 #include

// ------Prototype ------void foo(); Variables: address void bar(); // ------Definition ------void foo() A schematic representation of a variable { int x; printf(“The address of x in foo() is: %d\n”, &x); can be drawn as: } void bar() { printf(“Called from bar(),”); foo(); } Type // ------main ------Name Lifetime Value int main() Scope { The address of x in foo() is: 1244964 int i = 0; Called from bar(). The address of x in foo() is: 1244880 Address foo(); bar(); sleep(30000); return 0; } Chapter 5: Variables 25 Chapter 5: Variables 26

Variables: address Variables: address (aliases)

Concentrate on name, address and value If two variable names can be used to access the attributes same memory location, they are called aliases. Aliases are harmful to readability n Simplified representation: n Program readers must remember all of them.

n They are useful in certain circumstances. Example: Name Value int i, *iptr, *jptr;

Address iptr= &i; jptr= &i;

n A pointer, when de-referenced (*iptr) and the variable's name (i) are aliases Chapter 5: Variables 27 Chapter 5: Variables 28

type intptr = ^integer; Aliases var x, y: intptr;

Aliases can occur in several ways: begin

n Pointers new(x);

n Reference variables x^ := 1;

n Pascal variant record y := x;

n C and C++ unions y^ := 2;

n FORTRAN equivalence writeln(x^);

n Parameters end; Some of the original justifications for aliases are no longer valid; e.g. memory reuse in FORTRAN After the assignment of x to y, y^ and x^ both refer to the same n Replace them with dynamic allocations. variable, and the preceding code prints 2.

Chapter 5: Variables 29 Chapter 5: Variables 30

5 After the declarations, both x and y have After the call to new(x), x^ has been been allocated in the environment, but the allocated, and x has been assigned a values of both are undefined value equal to the location of x^, but x^ is

n Indicated in the diagram by shading in the still undefined circles indicating values.

x x

y y

Chapter 5: Variables 31 Chapter 5: Variables 32

After the assignment x^ := 1 The assignment y := x now copies the value of x to y, and so makes y^ and x^ aliases of each other (note that x and y are not aliases of each other)

x 1

x 1

y y

Chapter 5: Variables 33 Chapter 5: Variables 34

Finally, the assignment y^ := 2 results in Variables: type

Determines the range of values of variables x 2 Set the operations that are defined for values of that type Example: in Java, int type:

n Value range of –2,147,483,648 to 2,147,483,647 y n Operations: addition, subtraction, multiplication, division, and modulus.

Chapter 5: Variables 35 Chapter 5: Variables 36

6 Variables: value lvalue and rvalue

Contents of the location with which the Are the two occurrences of a in this variable is associated. expression the same? Abstract memory cell a := a + 1;

n The physical cell or collection of cells In a sense:

associated with a variable n The one on the left of the assignment refers to The smallest addressable cell is a byte. the location of the variable whose name is a But most types (system-defined or user defined) n The one on the right of the assignment refers to take more. the value of the variable whose name is a Abstract memory cell refers to the number of cells held by a variable. a := a + 1; n Example: float uses 4 bytes on most machines. address value

Chapter 5: Variables 37 Chapter 5: Variables 38

Assignment Assignment

To access an rvalue, a variable must be (Some languages) Different meaning to determined (dereferenced) first. assignment: locations are copied instead x := y of values.

y y

x x

Chapter 5: Variables 39 Chapter 5: Variables 40

Assignment Binding

Assignment by sharing. An alternative is to The assignment statement is really an allocate a new location, copy the value of instance of a more general phenomenon of y, and bind x to the new location attaching various kinds of values to names. The association of a name to an attribute is

y called binding

n Assignment statement binds a value to a location.

n Identifiers are bond to locations, types, and x other attributes at various points in the translations of a program. Chapter 5: Variables 41 Chapter 5: Variables 42

7 Binding Binding

Binding time. Bindings happen at different 3. Compile time and invisible points. n Example: bind a variable to a type in C or Java Possible binding times 4. Link time n Example: bind a call to a library function to the 1. Language design time function code. n Bind operator symbols to operations 5. Load time n Example: bind * to multiplication n Example: bind a C variable to a memory 2. Language implementation time cell. n Example: bind floating point type to a representation (IEEE floating-point format) 6. Runtime n Example: bind a nonstaticlocal variable to a n Example: the data type int in Java is bound to a range of values. memory cell

Chapter 5: Variables 43 Chapter 5: Variables 44

The Concept of Binding Static and Dynamic Binding

Consider the following: A binding is static

int C; n it occurs before run time and

C := C + 5; n It remains unchanged throughout program execution n Some of the bindings and their binding times A binding is dynamic are: n It occurs during execution or The type of C is bound at compiletime. The set of possible values of C is bound at compiler design n It can change during execution of the program time. As binding time gets earlier: The meaning of the operator + is bound at compiletime (when the types of its operands have been determined) n Efficiency goes up The internal representation of the literal 5 is bound at n Safety goes up compiler design time. The value of C is bound at run time. n Flexibility goes down

Chapter 5: Variables 45 Chapter 5: Variables 46

Type Bindings Variable Declarations

A variable must be bound to a data type before An explicit declaration is a program statement it can be referenced. used for declaring the types of variables. Two key issues in binding a type to an n Example: identifier: int x; n 1. How is the type specified? Advantage: safer, cheaper 2. When does the binding take place? n Disadvantage: less flexible How? – two kinds of declarations: An implicit declaration is a default mechanism 1. Explicit declarations for specifying types of variables (the first 2. Implicit declarations appearance of the variable in the program) When? - three kinds of type bindings: n Example: in FORTRAN, variables beginning with I-N 1. Static type binding are assumed to be of type integer. 2. Dynamic type binding 3. Type inference Chapter 5: Variables 47 Chapter 5: Variables 48

8 Variable Declarations Variable Declarations

Advantages: convenience Implicit declarations leave more room for Disadvantage: reliability (some typographical and error programmer errors cannot be detected. n Example: In FORTRAN variables left Intermediate position: Names for specific types undeclared will be implicitly declared as an must begin with a given character. integer. n Example: in Perl, variables of type scalar, array and hash structures begin with a $, @, or %, respectively.

n Advantages: Different namespaces for different type variables @apple vs. %apple vs. @apple The type of a variable is know through its name.

Chapter 5: Variables 49 Chapter 5: Variables 50

Dynamic Type Binding Dynamic Type Binding

The variable is bound to a type when it is n Disadvantages: Compiler’s type error detection is minimized. assigned a value in an assignment If RHS is not compatible with LHS, the type of LHS is changed as statement. opposed to generating an error.

n This issue also appears in static type binding languages like C and n JavaScript and PHP C++ n Example: in JavaScript Must be implemented by a pure interpreter rather than a compiler list = { 2, 4, 6, 8 }; n It is not possible to create machine code instructions whose operand types are not known at compile time. list = 17.3; High cost: n Dynamic binding of objects. n Type checking must be done at runtime

n Every variable must know its current type n Advantage: flexibility (generic program units) n A variable might have varying sizes because different type values require different amounts of storage.

n Must be interpreted. Chapter 5: Variables 51 Chapter 5: Variables 52

Type Inference Type Inference

Rather than by assignment statement, types n Illegal: are determined from the context of the fun square(x) = x * x reference. // can’t deduce anything ( a default value could be Type inferencing is used in some assigned) programming languages including ML, n Fixed Miranda, and Haskell. fun square(x : real) = x * x; Example: // use explicit declaration fun square(x) = (x : real) * x; n Legal: fun square(x) : real = x * (x : real); fun circumf(r) = 3.14159 * r * r; // infer r is real fun time10(x) = 10 * x; // infer s is integer

Chapter 5: Variables 53 Chapter 5: Variables 54

9 Storage Bindings & Lifetime Variables: lifetime

Allocation is the process of getting a cell from some pool of available cells. Categories of scalar variables by lifetimes: Deallocation is the process of putting a cell n Static back into the pool. n Stack-dynamic

The lifetime of a variable is the time during n Explicit heap-dynamic which it is bound to a particular memory cell. n Implicit hep-dynamic

n Begin: when the variable is bound to a specific cell

n Ends: when the variable is unbound from that cell.

Chapter 5: Variables 55 Chapter 5: Variables 56

Static Variables Static Variables

Bound to memory cells before execution and remains bound to the same memory cell Disadvantages: throughout execution n If a language only has static variables then

n Example: all FORTRAN 77 variables Recursion cannot be supported (lack of flexibility). n Example: C static variables Storage cannot be shared among variables Advantages: (more storage required) n Efficiency (direct addressing)

n No allocation/deallocation needed (which is run time overhead)

n History-sensitive subprogram support (retain values between separate executions of the subprogram) Chapter 5: Variables 57 Chapter 5: Variables 58

Stack-dynamic Variables Stack-dynamic Variables

Storage bindings are created for variables in Advantages: the run time stack when their declaration n Allows recursion statement are elaborated (or execution n Conserves storage reaches the code to which declaration is Disadvantages: attached), but types are statically bound. n Run time overhead for allocation and n If scalar, all attributes except address are deallocation. statically bound n Subprogram cannot be history sensitive

Example: local variables in C subprograms and Java n Inefficient references (indirect addressing) methods n Limited by stack size.

Chapter 5: Variables 59 Chapter 5: Variables 60

10 Explicit Heap-dynamic Variables Explicit Heap-dynamic Variables

Allocated and deallocated by explicit Disadvantages: directives, specified by the programmer, which take effect during execution. n Unreliable (forgetting to delete) n Difficult of using pointer and reference variables n Referenced only through pointers or correctly references n Inefficient. Example: dynamic objects in C++ (via new/delete, malloc/free) Example: Example: all objects in Java (except primitives) int *intnode; // create a pointer Advantages: … intnode = new int // create the heap-dynamic variable n Provides for dynamic storage management … delete intnode; // deallocate the heap-dynamic variable

Chapter 5: Variables 61 Chapter 5: Variables 62

Implicit Heap-dynamic Variables Summary Table

Allocation and deallocation caused by Variable Storage binding time Dynamic storage Type assignment statements and types not Category from binding determined until assignment. Static Before execution Static

n Example: All arrays and strings in Perl and JavaScript

n Example: all variables in APL Stack-dynamic When declaration is Run-time stack Static Advantage: highest degree of flexibility elaborated (run time) Disadvantages: Explicit heap- By explicit instruction Heap Static dynamic (run time) n Inefficient because all attributes are dynamic (a lot of overhead) Implicit heap- By assignment (run Heap Dynamic dynamic time) n Loss of error detection

Chapter 5: Variables 63 Chapter 5: Variables 64

Type Checking Type Checking

Generalizes the concept of operands and A compatible type is one that is either: operators to include subprograms and n Legal for the operator, or assignments: n Allowed under language rules to be implicitly n Subprogram is operator, parameters are converted to a legal type by compiler-generated operands. code. n Assignment is operator, LHS and RHS are n This automatic conversion is called coercion operands. Example: adding an int to a float in Java is allowed, Type checking is the activity of ensuring then int is coerced. that the operands of an operator are of compatible types. A type error is the application of an operator to an operand of an inappropriate type. Chapter 5: Variables 65 Chapter 5: Variables 66

11 Type Checking Strong Typing

If all type bindings are A programming language is strongly typed if

n Static: nearly all type checking can be static n Type errors are always detected.

n Dynamic: type checking must be dynamic n There is strict enforcement of type rules with no Static type checking is less costly (it is better to exceptions. catch errors at compile time) but it is also less n All types are known at compile time, i.e. are statically bound. flexible (fewer shortcuts and tricks). n With variables that can store values of more than one Static type checking is difficult when the type, incorrect type usage can be detected at run time. language allows a cell to store a value of Advantages: different types at different time, such as C n Strong typing catches more errors at compile time than unions, Fortran Equivalences or Ada variant weak typing, resulting in fewer run time exceptions. records. n Detects misuses of variables that result in type errors.

Chapter 5: Variables 67 Chapter 5: Variables 68

Which languages have strong Strong Typing vs. No Type typing? FORTRAN 77 is not because it does not check Coercion rules strongly affect strong typing parameters and because of variable equivalence n They can weaken it considerably statements. n Although Java has just half the assignments Ada is almost strongly typed but UNCHECKED coercions of C++, its strong typing is still weak (less CONVERSIONS is a loophole. effective than Ada). Haskell is strongly typed. n Languages such as Fortran, C and C++ have a great Pascal is (almost) strongly typed, but variant records deal of coercion and are less reliable than those with screw it up. little coercion, such as Ada, Java, and C#. C and C++ are sometimes described as strongly typed, In practice, languages fall on between strongly but are perhaps better described as weakly typed typed and untyped. because parameter type checking can be avoided and unions are not type checked.

Chapter 5: Variables 69 Chapter 5: Variables 70

Type Compatibility Name Type Compatibility

There are 2 different types of compatibility Easy to implement but highly restrictive: methods for structure (nonscalar) variables: n Subranges of integer types are not compatible n Name type compatibility with integer types. n Structure type compatibility Example: count cannot be assigned to index Name type compatibility (“name type IndexType is 1..100; equivalence”) means that two variables count: Integer; have compatible types if index: Indextype;

n They are defined in the same declaration or n Only two type names will be compared to

n They are defined in declarations that uses the determine compatibility. same type name.

Chapter 5: Variables 71 Chapter 5: Variables 72

12 Structure Type Compatibility Type Compatibility

Type compatibility by structure (“structural Consider the problem of two structured types: equivalence) means that two variables have n Are two record types compatible if they are structurally compatible types if their types have identical the same but use different field names? structures. n Are two array types compatible if they are the same More flexible, but harder to implement. except that the subscripts are different (e.g. [1..10] and n The entire structures of two types must be compared. [0..9])?

n May create types that are, but should not be n Are two enumeration types compatible if their compatible components are spelled differently? Example: Celsius vs. Fahrenheit n With structural type compatibility, you cannot type celsius= float; differentiate between types of the same structure (e.g. Fahrenheit = float; different units of speed, both float).

Chapter 5: Variables 73 Chapter 5: Variables 74

Scope Static Scope

The scope of a variable is the range of statements in a program over which it is visible. Also known as “lexical scope” n A variable is visible if it ca be referenced in a statement. In static scoping, the scope of a variable can be Typical cases: determined at compile time, based on the text of n Explicitly declared Þ local variables a program. n Explicitly passed to a subprogram Þ parameters To connect a name reference to a variable, the n The nonlocal variables of a program unit are those that are visible but not declared compiler must find the declaration

n Global variables Þ visible everywhere n Search process: search declarations, first locally, then The scope rules of a language determine how references to in increasingly larger enclosing scopes, until one is names are associated with variables. found for the given name. The two major schemes are static scoping and dynamic n Enclosing static scopes to a specific scope are called scoping. its static ancestors; the nearest static ancestor is called a static parent.

Chapter 5: Variables 75 Chapter 5: Variables 76

Blocks Blocks

A block is a section of code in which local Variables can be hidden from a unit by variables are allocated/deallocated at the having a “closer” variable with the same start/end of the block. name. Provides a method of creating static C++ allows access to “hidden” variables scopes inside program units. with the use of :: scope operator.

Introduced by ALGOL 60 and found in n Example: if x is a hidden in a most PLs. subprogram by a named x, the global could be reference as class_name::x

n Ada: unit.x

Chapter 5: Variables 77 Chapter 5: Variables 78

13 Example of Blocks Scope

C and C++ Common Lisp Consider the example: for (…) { (let ((a 1) int index; (b foo) Assume MAIN calls A and B … (c)) } A calls C and D (setqa (* a a )) (bar a b ) ) B calls A and E Ada Declare LCL: FLOAT; begin … end

Chapter 5: Variables 79 Chapter 5: Variables 80

Static Scope Example Static Scope Example

The desired call graph The potential call graph

MAIN MAIN A

C A B MAIN MAIN D C D E A B A B B

E C D E C D E

Chapter 5: Variables 81 Chapter 5: Variables 82

Static Scope Evaluation Dynamic Scope

Suppose now that E() needs to get access to a Based on calling sequences of program units, variable in D() not their textual layout. One solution is to move E() inside the scope of D() Reference to variables are connected to n But then E can no longer access the scope of B declarations by searching back through the Another solution is to move the variables defined in chain of subprogram calls that forced execution D to main at this point. n Suppose x was moved from D to main, and another x Used in APL, Snobol and LISP was declared in A, the latter will hide the former. n Note that these languages were all (initially) n Also having variable declared very far from where they implemented as interpreters rather than compilers. are used is not good for readability. Consensus is that PLs with dynamic scoping Overall: static scope often encourages many global lead to programs which are difficult to read and variables. maintain. Chapter 5: Variables 83 Chapter 5: Variables 84

14 Scope Example Static vs. Dynamic Scoping

MAIN Advantages of Static Scoping: - declaration of x SUB1 MAIN calls SUB1 n Readability - declaration of x - SUB1 calls SUB2 n Locality of reasoning ... SUB2 uses x call SUB2 n Less run time overhead ... Disadvantages:

n Some loss of flexibility SUB2 • Static scoping Advantages of Dynamic Scoping ... • reference to x is to MAIN’s x - reference to x - • Dynamic scoping n Some extra convenience ... • reference to x is to SUB1’s x Disadvantages

... n Loss of readability call SUB1 n Unpredictable behavior (minimal parameter passing) … Chapter 5: Variables 85 n More run-time overhead.Chapter 5: Variables 86

Scope vs. Lifetime Referencing Environment

While these two issues seem related, they can The referencing environment of a differ. statement is the collection of all names In Pascal, the scope of a local variable and the that are visible in the statement. lifetime of the local variable seem the same. In a static-scoped language, it is the local In C/C++, a local variable in a function might variables plus all of the variables in all the be declared static but its lifetime extends over enclosing scopes. the entire execution of the program and In a dynamic-scoped language, the therefore, even through it is inaccessible, it is referencing environment is the local still memory. variable plus all visible variables in all active subprograms.

Chapter 5: Variables 87 Chapter 5: Variables 88

Named Constants Named Constants

A named constant is a variable that is Advantages: bound to a value only when it is bound to n Readability storage. n Maintenance The value of a named constant can not change while the program is running. The binding of values to named constants can be either static of dynamic

n const int length = 5 * x; Type Name Lifetime Value n final flow rate = 1.5*values; Scope

Chapter 5: Variables 89 Chapter 5: Variables 90

15 Named Constants Variable Initialization

Languages The binding of a variable to a value at the

n Pascal: literals only time it is bound to storage is called

n Modula-2 and FORTRAN 90: constant- initialization. value expressions Initialization is often done on the n Ada, C++, and Java: expressions of any declaration statement kind n Example: In Java Advantages int sum = 0;

n Increases readability without loss of effective.

Chapter 5: Variables 91 Chapter 5: Variables 92

Summary

Case sensitivity and the relationship of names to special words represent design issues of names Variables are characterized by the sextuples: name, address, value, type, lifetime, scope Binding is the association of attributes with program entities Scalar variables are categorized as: static, stack dynamic, explicit heap dynamic, implicit heap dynamic Strong typing means detecting all type errors

Chapter 5: Variables 93

16