Indirection.mesa
Copyright Ó 1992 by Xerox Corporation. All rights reserved.
Created by Christian Jacobi, March 11, 1992
Christian Jacobi, May 27, 1992 11:37 am PDT
A mechanism which allows delayed specification of data.
Indirection is pretty simple; the value of this package lies more in the type code with the implied meaning then in its procedures.
Indirection is different from lazy evaluation as multiple invocations (Generate) may return different results.
Indirection: CEDAR DEFINITIONS ~
BEGIN
GenerateProc: TYPE ~ PROC [createData, callData: REF] RETURNS [result: REF ¬ NIL];
Handle: TYPE ~ REF HandleRec;
HandleRec:
TYPE ~
RECORD [
generate: GenerateProc,
createData: REF ¬ NIL
];
InlineGenerate:
PROC [h: Handle, callData:
REF ¬
NIL]
RETURNS [
REF] ~
INLINE {
RETURN [ h.generate[h.createData, callData] ]
};
Generate: PROC [h: Handle, callData: REF ¬ NIL] RETURNS [REF];
Usage
To specify indirect data use ... ← NEW[Indirection.HandleRec ← [MyProc, createData]];
To evaluate indirect data use Indirection.Generate[...];
END.