Article View: comp.lang.postscript
Article #1854Re: PostScript coding style question
From: Dick Dunn
Date: Fri, 21 Aug 1992 16:03
Date: Fri, 21 Aug 1992 16:03
33 lines
1526 bytes
1526 bytes
bradlee@cg-atla.UUCP (Rob Bradlee) writes:
>/utility_procedure {
> mark
...stuff...
> {
> % test was true. Process the rest of the items on the stack.
> }
> {
> % test failed. cleanup.
> cleartomark
> } ifelse
>} def
>Is the cleartomark a legitimate way to make sure you've left the stack in good
>shape or a cheap trick that absolves you from the effort of thinking?
Glenn Reid took the "cheap trick" position, which I think is true most of
the time. However, if testing and processing arguments, managing inter-
mediate results, etc., gets complex enough, I think the mark...cleartomark
is cleaner and clearer than a proc which ends something like:
} {
pop pop
} ifelse
pop
} {
exch pop pop
} ifelse
...as you try to dig your way back and balance the stack at the end. This
is hardest in a proc which is coping with error situations and trying to
invoke error handlers with the right stack context.
--
Dick Dunn rcd@raven.eklektix.com -or- raven!rcd Boulder, Colorado
Cats!
Technical Details
Message-ID:
<1992Aug21.160313@eklektix.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!usenet.coe.montana.edu!caen!hellgate.utah.edu!csn!raven!rcdReferences:
<10087@cg-atla.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!usenet.coe.montana.edu!caen!hellgate.utah.edu!csn!raven!rcd From: rcd@raven.eklektix.com (Dick Dunn) Newsgroups: comp.lang.postscript Subject: Re: PostScript coding style question Summary: not so bad in error-handling cases Message-ID: <1992Aug21.160313@eklektix.com> Date: 21 Aug 92 16:03:13 GMT References: <10087@cg-atla.UUCP> Organization: eklektix - Boulder, Colorado Lines: 33