XMesaCmplr13g.mesa  23-Aug-87 12:33:29
Jim Foote January 20, 1988 10:28:41 am PST
<< Implementation for XMesaCmplr13Defs4. Declares 2 types of simple procedures: one with a parameter and one without. Then a few procedure variables and procedure constants of these types are declared. Also declares procedures which return procedures as results and procedures which pass procedures as parameters. >>
DIRECTORY
XMesaCmplr13Defs4;
XMesaCmplr13g: PROGRAM
EXPORTS XMesaCmplr13Defs4 =
BEGIN
Proc1: PUBLIC TYPE = PROCEDURE RETURNS [i: INTEGER];
ProcVar1: PUBLIC Proc1 ¬ NIL;
Type11: PUBLIC Proc1 = { RETURN [1] };
Type12: PUBLIC Proc1 = { RETURN [2] };
DefaultProc1: PUBLIC Proc1 ¬ Type11;
ReturnProc1: PUBLIC PROCEDURE [i: INTEGER] RETURNS [p: Proc1] = {
SELECT i FROM
1 => RETURN[Type11];
2 => RETURN[Type12];
ENDCASE => RETURN[DefaultProc1]; };
PassProc1: PUBLIC PROCEDURE [p: Proc1] RETURNS [i: INTEGER] = {
RETURN [p[]]; };
Proc2: PUBLIC TYPE =PROCEDURE [c: CARDINAL] RETURNS [rc: CARDINAL];
ProcVar2: PUBLIC Proc2 ¬ NIL;
Type21: PUBLIC Proc2 = { RETURN [c+1*c] };
Type22: PUBLIC Proc2 = { RETURN [c+2*c] };
DefaultProc2: PUBLIC Proc2 ¬ Type22;
ReturnProc2: PUBLIC PROCEDURE [i: INTEGER] RETURNS [p: Proc2] = {
SELECT i FROM
1 => RETURN[Type21];
2 => RETURN[Type22];
ENDCASE => RETURN[DefaultProc2]; };
PassProc2: PUBLIC PROCEDURE [p: Proc2] RETURNS [i: INTEGER] = {
RETURN [p[2]]; };
END.