Chapter 10
Intermediate Program Structuring


10.0 Chapter Goals
10.1 Introduction

Part A--Scope and Visibility Issues

10.2 Blocks, Global and Local Variables, Side Effects
     10.2.1 Procedure Blocks and Scope
     10.2.2 Side effects and Counting Loops
     10.2.3 Other Global side effects
     10.2.4 Nested Procedure Scopes
10.3 Parameters Revisited
     10.3.1 The Scope of Parameters
     10.3.2 Parameters and side effects
10.4 Procedure Types and their Variables
10.5 Local Modules--Scope and Visibility Rules
     10.5.1 Standard Identifiers and Scope
     10.5.2 Dynamic Modules
10.6 An Extended Example--Fibonacci Sequences
10.7 Library Modules--Scope and Visibility Rules
     10.7.1 Access to Imported Libraries at Inner Scopes
     10.7.2 Visibility in Library Modules
     10.7.3 Opaque Types--a Brief Introduction

Part B--Program Control and Error Handling Issues

10.8 Transfer of Control
     10.8.1 GOTO and Other Noxious Weeds
     10.8.2 RETURN in a Regular Procedure
     10.8.3 Repetition Revisited--The Generalized LOOP Statement
10.9 Error Handling Revisited
     10.9.1 Typical Library Errors
10.10 Controlling Program Termination
     10.10.1 HALT and Abnormal Termination
10.11 FINALLY: Termination Detection and Cleanup
10.12 Exceptions
     10.12.1 Language Exceptions
     10.12.2 Library Exceptions
     10.12.3 Handling Exceptions
     10.12.4 Exceptions and Termination
     10.12.5 User-Defined Exceptions
10.13 An Extended Example--Fractions and Exceptions
10.14 Chapter Summary
10.15 Assignments
Contents