PROCANY


Motivation

We need a safe mechanism to talk about the class of all procedures. PROCANY is a subtype of ADDRESS, and is a supertype of all PROCEDURE types.

Implementation

PROCANY is a subtype of ADDRESS, and a supertype of all PROCEDURE types. In order to prevent nested procedures from escaping, we add one runtime check. When a procedure formal is passed as an argument, where the corresponding formal is PROCANY or ADDRESS, we must check that the procedure is not nested.

Examples

PROCEDURE p() =
  BEGIN
  END p;

PROCEDURE q(x:PROCANY) =
  BEGIN
  END q;

PROCEDURE r(x:PROCEDURE ()) =
  BEGIN
    q(x);     (* legal, incurs runtime check to ensure
		 that x is not a nested procedure *)
  END r;

q(p)  (* legal, no runtime check *)


Other SPIN Modula-3 changes

May 20, 1996

whsieh@cs.washington.edu