🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.lang.postscript
2 messages
2 total messages Started by Rob Bradlee Mon, 10 Aug 1992 14:37
Is cleartomark good PS programming style?
#1807
Author: Rob Bradlee
Date: Mon, 10 Aug 1992 14:37
31 lines
1269 bytes

Here is PostScript coding style question for all you gurus:  Let's say you
have a PS procedure that does some like this

/utility_procedure {
	mark
	%
	% imagine PS code here to do some useful things and load up the stack
	%
	% Now imagine some PS code that does a test based on some of the 
	% stack info to see if it's worth processing the rest of the data
	% on the stack
	{
	% 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?
Your opinions, please.
-- 
Rob Bradlee  w:(508)-658-5600 X5153 
Agfa Corporation.                      ...!{decvax}!cg-atla!bradlee
200 Ballardvale St.                        bradlee@cg-atla.agfa.com
Wilmington, Mass. 01887 
Re: Is cleartomark good PS programming style?
#1842
Author: 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. :-)
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads