🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.postscript
Article #7470

Re: An Idea to Help Make Postscript Easier to Read (and Write)

#7470
From: Chung-Pang Lai
Date: Tue, 06 Sep 1988 20:19
75 lines
3693 bytes
In article <940@helios.ee.lbl.gov> forrest@ux1.lbl.gov (Jon Forrest) writes:
]
]What about a "compiler" that converts standard postscript into
]what I'll call infix/function form? 
]
This is an idea, but I think it is hard to maintain the source and the 
translated copy of the same postscript program.

I am also new to postscript.  I notice the hardest thing to read a postscript
program is to tell which argument belong to which operator.
Once you are familiar with the operator set (some 200+ built-in operators),
you can read your postscript code easily.  After that you have to get familiar
with all the new procedures or operators that are developed locally in your
company to understand what argument goes to what operator again.  

e.g.  Try reading the following most common postscript code.

	/Times-Roman findfont 6 scalefont setfont (A) show showpage 

You have to look up the reference manual to know that findfont takes one
argument from the stack and leaves one.  scalefont takes two from the
stack and leaves one.  And setfont takes one and leaves none.  And show
takes one and leaves none, showpage takes none and leaves none.  I learnt
these five after awhile, but I still have to learn the rest 200+ operators.
And I have to look up the reference manual from time to time to check if
I passed the arguments correctly.

When I took the postscript class at Adobe Systems, I discuss this issue with
the instructor.  I came up with a suggestion, but the discussion leaded to
no conclusion.

My suggestion was:
Two OPTIONAL noise characters can be used by the programmer to delimit the 
scope of the procedure invocations.  I understand {} are reserved for 
procedure declaration, I steal this two characters just for the purpose of 
illustrating my idea below.  Another two unique symbols should be defined
by the postscript language to avoid conflicts.

Assuming postscript interpretor treats { and } as noise, i.e. read and ignore,
then I can rewrite the above line as follows:

	{{{/Times-Roman findfont} 6 scalefont} setfont} {(A) show} {showpage}

This shows clearly that /Times-Roman is used by findfont.
The result from findfont and 6 are used by scalefont.
The result from scalefont is used by setfont
(A) is used by show.
nothing is used by showpage.

These delimitors should be optional and can be used like comments to help
programmer read the code.  Usage as below may be more practical:

	{{/Times-Roman findfont} 6 scalefont} setfont
	(A) show
	showpage

Do you think it is more readable?
I'll bet some LISP haters hate my idea :-)
It is just optional, don't blame me for it.

The price:
A lot of noise has to be transmitted through the cable to the printer.
Take up two special symbols.
All good candidates are used for other purpose already, e.g. {} [] <> ().

The gain:
An optional way to make code easier to maintain.  Will not hurt existing
drivers because postscript produced by software are not meant to be read
by human and hence delimitors not needed.

-- 
.signature under construction ...

{cbosgd,fortune,hplabs,seismo!ihnp4,ucbvax!hpda}!nsc!daisy!cplai    C.P. Lai
Daisy Systems Corp, 700B Middlefield Road, Mtn View CA 94039.  (415)960-6961
Technical Details
Message-ID: <1574@daisy.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!husc6!uwvax!rutgers!mailrus!ames!sgi!daisy!cplai
References: <940@helios.ee.lbl.gov>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!husc6!uwvax!rutgers!mailrus!ames!sgi!daisy!cplai
From: cplai@daisy.UUCP (Chung-Pang Lai)
Newsgroups: comp.lang.postscript
Subject: Re: An Idea to Help Make Postscript Easier to Read (and Write)
Message-ID: <1574@daisy.UUCP>
Date: 6 Sep 88 20:19:13 GMT
References: <940@helios.ee.lbl.gov>
Reply-To: cplai@daisy.UUCP (Chung-Pang Lai)
Organization: Daisy Systems Corp., Mountain View, Ca.
Lines: 75