🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.postscript
Article #7487

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

#7487
From: Steve McCanne
Date: Tue, 13 Sep 1988 02:11
53 lines
2293 bytes
In article <1351@ge-dab.GE.COM> cochran@ge-dab.GE.COM (Craig Cochran) writes:
...
>The high-level language that could do all this for PostScript would
>most certainly crawl, since functions would have to maintain variables
>rather than use the stack - a loss in memory and CPU cycles.

There has been a lot of talk about a high-level language (to PostScript
compiler) being forced to use variable names rather than stack locations 
for storage management.  However, there's nothing wrong with the conventional 
approach of allocating stack space for local variables (and function 
arguments).  The PreScript compiler, in fact, does just this.

Here's the function example Glenn Reid gave:

>% sample procedure call:
>	(Text) 100 100 12 /Times-Roman SETTEXT
>
>% approach 1:
>	/SETTEXT { %def
>	    findfont exch scalefont setfont moveto show
>	} def
>% approach 2:
>	/SETTEXT { %def
>	    /arg5 exch def
>	    /arg4 exch def
>	    /arg3 exch def
>	    /arg2 exch def
>	    /arg1 exch def
>	    arg5 findfont arg4 scalefont setfont
>	    arg2 arg3 moveto arg1 show
>	} def
>

A compiler that kept track of stack locations, could produce
the code in approach 1.

>Which of these is easier for you to understand?

It doesn't matter which *result* is easier to read; it matters which 
*source* file is easier to read.  (Who would compare assembler
output for readability in register compilers?)  Specifically, 
the PreScript source would look (almost) like:

function SETTEXT(string s; int x, y, scale_factor; name f)
{
	setfont(scalefont(findfont(f), scale_factor));
	moveto(x, y);
	show (s);
}


Steve McCanne 
mccanne@helios.ee.lbl.gov
Technical Details
Message-ID: <963@helios.ee.lbl.gov>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!lll-winken!lll-tis!mordor!joyce!ames!pasteur!helios.ee.lbl.gov!hot.ee.lbl.gov!mccanne
References: <940@helios.ee.lbl.gov> <5361@vdsvax.steinmetz.ge.com> <1619@crete.cs.glasgow.ac.uk> <1351@ge-dab.GE.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!lll-winken!lll-tis!mordor!joyce!ames!pasteur!helios.ee.lbl.gov!hot.ee.lbl.gov!mccanne
From: mccanne@hot.ee.lbl.gov (Steve McCanne)
Newsgroups: comp.lang.postscript
Subject: Re: An Idea to Help Make Postscript Easier to Read (and Write)
Message-ID: <963@helios.ee.lbl.gov>
Date: 13 Sep 88 02:11:33 GMT
References: <940@helios.ee.lbl.gov> <5361@vdsvax.steinmetz.ge.com> <1619@crete.cs.glasgow.ac.uk> <1351@ge-dab.GE.COM>
Sender: usenet@helios.ee.lbl.gov
Reply-To: mccanne@helios.ee.lbl.gov (Steve McCanne)
Organization: Lawrence Berkeley Laboratory, Berkeley
Lines: 52