-- SettingFoos.mesa
--  last edit     
  

SettingFoos: PROGRAM =

BEGIN

SubSubFoo: TYPE = RECORD[fill: CARDINAL];
SubFoo: TYPE = RECORD[fill: CARDINAL];
Foo: TYPE = RECORD[fill: CARDINAL];

SubFooShape: TYPE = RECORD[fill: CARDINAL];
FooShape: TYPE = RECORD[fill: CARDINAL];

SetASubFooProc: TYPE = PROCEDURE[
		shapeAndCaseInfo: SubFooShape,
		getOneSubSubFoo: PROCEDURE
		];

SetAFooProc: TYPE = PROCEDURE[
		shapeAndCaseInfo: FooShape,
		getOneSubFoo: PROCEDURE[SetASubFooProc]
		];
		
ExecuteInMonitor: PROCEDURE[PROCEDURE];
		

GetAFoo: PUBLIC PROCEDURE[
		foo: Foo,
		send: SetAFooProc,
		entry: BOOLEAN
		] =
	BEGIN
	GAF: PROCEDURE =
		BEGIN
		shapeInfo: FooShape; -- compute foo shape
		--
		-- iteration info
		--
		
		GetOneSubFoo: PROCEDURE[sendIt: SetASubFooProc] =
			BEGIN
			subFoo: SubFoo; -- first locate the subfoo to send
			GetASubFoo[subFoo, sendIt, FALSE];
			-- update the iteration info
			END;
		
		-- compute shape info
		-- initialize the iteration info
		
		send[shapeInfo, GetOneSubFoo];
		END;
	IF entry THEN ExecuteInMonitor[GAF] ELSE GAF[];
	END;
	
SetAFoo: PUBLIC PROCEDURE[
		foo: Foo,
		shapeAndCaseInfo: FooShape,
		getOneSubFoo: PROCEDURE[SetASubFooProc],
		entry: BOOLEAN
		] =
	BEGIN
	SAF: PROCEDURE =
		BEGIN
		-- iteration info
		
		-- abandon old shape
		
		-- create new shape
		
		-- Iterate through new shape
			DO
			subFoo: SubFoo ← CreateSubFoo[];
			SetTheSubFoo: SetASubFooProc =
				BEGIN
				SetASubFoo[subFoo, shapeAndCaseInfo, getOneSubSubFoo, FALSE];
				END;
			-- record the sub foo in local data structure
			getOneSubFoo[SetTheSubFoo];
			ENDLOOP;
		END;
	IF entry THEN ExecuteInMonitor[SAF] ELSE SAF[];
	END;
	
CreateSubFoo: PROCEDURE RETURNS[SubFoo];

GetASubFoo: PROCEDURE[
	subFoo: SubFoo,
	send: SetASubFooProc,
	entry: BOOLEAN
	];
	
SetASubFoo: PUBLIC PROCEDURE[
		foo: Foo,
		shapeAndCaseInfo: SubFooShape,
		getOneSubSubFoo: PROCEDURE,
		entry: BOOLEAN
		];	
			
END..


--  November 3, 1982 10:41 am: Sturgis, settingFoos