FILE: FuglemanImpl.mesa
Last Edited by Mitchell, August 16, 1982 2:01 pm
FuglemanStdImpl:
CEDAR PROGRAM
EXPORTS Fugleman =
BEGIN OPEN Fugleman;
Implementation types
Handle: TYPE = REF Rep; -- declare the concrete type locally
Rep:
PUBLIC TYPE =
RECORD[
count: INT,
flag: BOOLEAN ← TRUE,
mumble: INT];
FugleFailure: PUBLIC ERROR = CODE;
NewFugleman:
PUBLIC PROCEDURE
RETURNS [Handle] =
BEGIN
RETURN [NEW[Rep ← [count: 5, mumble: -10]]];
END;
Operations on a Fugleman
Print:
PUBLIC PROCEDURE [h: Handle] =
BEGIN
-- some body would go here
END;
Check:
PUBLIC PROCEDURE [h: Handle] =
BEGIN
IF h.count>100 OR h.mumble<0 AND NOT h.flag THEN ERROR FugleFailure; -- example only
END;
SomeProc:
PUBLIC PROCEDURE [h: Handle, otherArgument:
INT]
RETURNS [
r: INT] =
BEGIN
IF otherArgument>100 THEN otherArgument ← 100;
h.count ← otherArgument;
r ← 17;
END;
END. -- FuglemanStdImpl
CHANGE LOG