Chapter 6: Part III

Records

Compile Time Descriptors

Record Operations

Comparing Records and Arrays

  1. Access to array elements is much slower than access to record fields, because subscripts are dynamic (field names are static)
  2. Dynamic subscripts could be used with record field access, but it would disallow type checking and it would be much slower

Unions

Unions Examples

Unions (cont)

Sets

Pointers Problems with

Examples

Pascal: used for dynamic storage management only

Ada: a little better

Examples (cont)

C and C++

Pointer assignment

Examples: Fortran

Examples C++ Reference Types

Examples: Java

Pointers: Evaluation

  1. Dangling pointers and dangling objects are problems, as is heap management
  2. Pointers are like goto's--they widen the range of cells that can be accessed by a variable
  3. Pointers or references are necessary for dynamic data structures--so we can't design a language without them

Pointers: Implementation

Dangling pointer problem

Tombstone: extra heap cell that is a pointer to the heap-dynamic variable


Dangling Pointer Problem: Locks and Keys

Heap Management

Reference Counters maintain a counter in every cell that store the number of pointers currently pointing at the cell

Garbage Collection


Notes