Chapter 5

Names and Other Concepts

Related to Variables



Overview

  1. Name
  2. Address
  3. Value
  4. Type
  5. Lifetime
  6. Scope: static and dynamic


5.2 Names



Name Design Issue: Length



Name Design Issue: Connectors



Name Design Issue: Case Sensitivity



Name Design Issue: Special Words



FORTRAN: A Convention Breaker



Memory Organization



Binding



Binding Times



Kinds of Bindings



Variables



Variable Attribute 1: Name



Variable Attribute 2: Address



Aliases



FORTRAN EQUIVALENCE



Variable Attribute 3: Value



Variable Attribute 4: Type



5.4 Static or Dynamic Type Binding



5.4 Dynamic Type Binding



Type Inference



Type Checking




5.6 Strong Typing



5.7 Type Compatibility



5.7 Type Compatibility



Variable Attribute 5: Lifetime



5.4 Categories of lifetimes

  1. Static--bound to memory cells before execution begins and remains bound to the same memory cell throughout execution. e.g. all FORTRAN 77 variables, C static local variables, C global variables
  2. Stack-dynamic--Storage bindings are created for variables when their declaration statements are elaborated.
  3. Explicit heap-dynamic--Allocated and deallocated by explicit directives, specified by the programmer, which take effect during execution
  4. Implicit heap-dynamic--Allocation and deallocation caused by assignment statements e.g. all variables in APL; all strings and arrays in Perl and JavaScript


Lifetimes and Deallocation




Variable Attribute 6: Scope



Blocks



Local and Nonlocal Variables



Nonlocals in outer blocks



Outer Blocks and Static Scope Rules



5.9 Referencing Environments



Nonlocals and Hiding



Referencing environments and active routines



Referencing Envts and Dynamic Scope


5.8 Nonlocal Scope and Variables Declared in Other Units



Dynamic Scope



Dynamic Scope Example



5.9 Scope and Lifetime



5.11 Named Constants



5.12 Variable Initialization