Re: Postscript as a target language? (Zalman Stern)
Mon, 9 Aug 1993 07:11:00 GMT

          From comp.compilers

Related articles
Postscript as a target language? (1993-08-08)
Re: Postscript as a target language? (1993-08-09)
Re: Postscript as a target language? (1993-08-09)
Re: Postscript as a target language? (1993-08-09)
Re: Postscript as a target language? (Chris DONAWA) (1993-08-09)
Re: Postscript as a target language? (1993-08-10)
| List of all articles for this month |

Newsgroups: comp.compilers
From: (Zalman Stern)
Keywords: courses
Organization: Adobe Systems Incorporated
References: 93-08-040
Date: Mon, 9 Aug 1993 07:11:00 GMT

Al Stavely writes:
[How about using PostScript as a language target for an undergrad compiler

I guess some people view PostScript as the programming equivalent of two
willing members of the appropriate sex, lots of leather toys, and a big tub
o' whipped cream. Fortunately, as I recall, the age of consent in New Mexico
is younger than most undergrads so we can dispense with concerns of your
being arrested for contributing to the delinquency of minors :-)

[Our esteemed moderator writes:]
> [Makes sense to me. The first compiler I wrote, for a course assignment,
> turned APL into Basic. Worked, too. I wrote it in Trac, but that's a
> separate issue. The only problem with Postscript is that as a stack
> language, it doesn't give you a place to do register allocation. -John]

No problem, we'll just have the DSC committee to add some register
allocation comments. Something like:
%%RegistersNeeded: 42
%%AllocateRegister: /dict_key 3
(Explanations left as an exercise to the reader. As with many subtleties of

Seriously, one runtime model is to allocate a single dictionary with say 32
keys. This could be used as a temporary store with values spilled to the
stack as necessary. Though this might not be the best way to do things, it
has some merit. (Its certainly better than allocating a dictionary for each
activation record.) I'm not sure how dictionary lookup compares to index
operations, but there is caching machinery in most PostScript interpreters
so looking up recently used keys is fast.

Of course a student should get an automatic A for having his or her compiler
output winning the obfuscated PostScript contest. I would encourage you to
provide a strong debugging procset. Perhaps going so far as to add debugging
hooks into an available interpreter. (Think of this as self-preservation.
None of us wants to see the headline "New Mexico Professor Gunned Down by
Student in PostScript Induced Rage.") You should also have some standard
benchmarks. One can grade on speed and memory consumption. It would be cool
if the benchmarks are derived from real PostScript documents (either
application or human generated). Then the compiler output can be compared to
"hand coded" PostScript.

[Disclaimer: I don't work on the PostScript interpreter. The name PostScript
is a registered trademark of Adobe Systems Incorporated. Please imagine an
'R' in a circle everywhere PostScript appears in this posting. Adobe policy
states netnews is niether an amusement nor a time waster. So don't laugh at
this highly productive post.]
Zalman Stern (415) 962 3824
Adobe Systems, 1585 Charleston Rd., POB 7900, Mountain View, CA 94039-7900

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.