🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.postscript
Article #1842

Re: Is cleartomark good PS programming style?

#1842
From: Jim DeLaHunt
Date: Fri, 21 Aug 1992 03:33
32 lines
1895 bytes
Rob Bradlee writes:

> 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?

The way I would phrase the question is: is it a legitimate and useful
technique to pass a variable number of parameters on the operand stack, 
delimited with a 'mark'?  In my opinion, yes, absolutely.  Sometimes
you really want a variable number of arguments, sometimes you really do
want to "throw out all remaining arguments", and mark ... cleartomark
provides a great way to do that.

Here's how I've used it:  my software reads feature invocation code from a
PPD (PostScript Printer Description) file.  I enclose the invocation code
in mark ... cleartomark and a stopped context, so that if my file goes to
a printer that doesn't support that feature, the feature invocation will
turn into a no-op.

For instance, here's how my software invokes letter-size paper:
	[ {
	statusdict /lettertray get exec
	} stopped cleartomark

Is it a cheap trick?  Well, any legitimate technique can also be used as
a cheap trick that absolves one from thinking.  "0 setlinewidth" comes to
mind.

	--Jim DeLaHunt, Developer Support, Adobe Systems Incorporated	
delahunt@adobe.com	...!{apple,decwrl}!adobe!delahunt      +1-415-962-3790
In programming style my word is law.  I work for Developer Support. :-)
Technical Details
Message-ID: <1992Aug21.033348.29244@adobe.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!olivea!hal.com!decwrl!adobe!delahunt
References: <10077@cg-atla.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!olivea!hal.com!decwrl!adobe!delahunt
From: delahunt@adobe.com (Jim DeLaHunt)
Newsgroups: comp.lang.postscript
Subject: Re: Is cleartomark good PS programming style?
Summary: sure it is.
Keywords: style
Message-ID: <1992Aug21.033348.29244@adobe.com>
Date: 21 Aug 92 03:33:48 GMT
References: <10077@cg-atla.UUCP>
Sender: usenet@adobe.com (USENET NEWS)
Followup-To: comp.lang.postscript
Distribution: comp
Organization: Adobe Systems Incorporated
Lines: 32