| |
 |
|
This program implements a simple Pair class. It uses the Util.WriteInt
method of the FMCP compiler in order to produce output when executed.
MODULE FMCPTest;
TYPE
Elem = EXTENSIBLE RECORD (ANYREC)
x: INTEGER;
END;
ExtElem = RECORD (Elem)
y: BOOLEAN;
END;
Pair = EXTENSIBLE RECORD (ANYREC)
fst: Elem;
snd: Elem;
END;
PROCEDURE (IN this: Pair) SetFst (e: Elem): Pair, NEW, EXTENSIBLE;
BEGIN RETURN NEW Pair (fst = e, snd = this.snd) END SetFst;
BEGIN
util.WriteInt(NEW Pair(fst = NEW Elem(x = 1), snd = NEW Elem(x =
2)).SetFst(NEW ExtElem(y = TRUE, x = 1)).fst.x)
END FMCPTest.
|