Article View: comp.lang.postscript
Article #8035local variables implementation
From: Dinh Le
Date: Fri, 24 Feb 1989 03:03
Date: Fri, 24 Feb 1989 03:03
48 lines
1855 bytes
1855 bytes
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
Technical Details
Message-ID:
<5673@sdcrdcf.sm.unisys.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!oberon!sm.unisys.com!far-side.sm.unisys.com!dinhShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!oberon!sm.unisys.com!far-side.sm.unisys.com!dinh From: dinh@far-side.sm.unisys.com (Dinh Le) Newsgroups: comp.lang.postscript Subject: local variables implementation Message-ID: <5673@sdcrdcf.sm.unisys.com> Date: 24 Feb 89 03:03:29 GMT Sender: news@sm.unisys.com Reply-To: dinh@sm.unisys.com (Dinh Le) Organization: Unisys Santa Monica Lines: 48