dinh@far-side.sm.unisys.com (Dinh Le) (02/24/89)
I have problems implementing local variables in postscript and wonder if
there are solutions (good or bad). Here is a description:
Using C-prolog, I wrote a LOGO compiler using postscript as the target
language. Most commands in LOGO can easily be simulated by postscript;
however, I have a hard time trying to simulate local variables declara-
tion in a LOGO procedure and the return function inside a LOGO procedure.
For example, if I have the following procedure
procedure hilbert (size level parity)
begin
if level = 0 then return;
left(parity * 90); /* turn the turtle left by deg */
hilbert(size level-1 -parity);
forward(size); /* forward turtle by size units */
right(parity * 90); /* turn the turtle right by deg */
hilbert(size level-1 parity);
forward size;
hilbert(size level-1 parity);
right(parity * 90);
forward(size);
hilbert(size level-1 -parity);
left(parity * 90);
end
I've used following solution for local variables implementation,
but it doesn't work
/hilbert {
/hilbertdict begin
/size exch def
/level exch def
/parity exch def
...
end
} def
Can someone spot the mistake(s) and suggest a solution for
local variable implementation? Is there a nice way to
implement the return function which exit from a postscript
procedure?
Thanks for any hints,
'Dinh