This is an old revision of the document!


PostScript

This is an implementation of PostScript1) language level 3. The full language is implemented except for graphics operators.

Most people may know PostScript as a page description language for printers2). But actually PostScript is a full fledged, turing complete programming language with dedicated support for vector graphics and fonts.

This implementation is about the programming language without the graphical aspects. PostScript is a stack based language, a descendent of Forth3) and resembling the famous HP4) RPN5) calculator programming model.

Load the package [PostScript] from the Cincom Public Store into your VisualWorks image.

Tests are in package [PostScript Testing].

PostScript is now a prerequisite of bundle {PDFtalk}.

  • need it for PDF, especially CMaps
  • beauty of the language
  • used to programm UIs with Display PostScript on a Sun Solaris NeWS workstation

To add two numbers, the numbers are entered first and then add:

3 4 add

This works with a stack, the so called operand stack (or just stack):

        % ||  <       Initial empty operand stack
3       % || 3 <      the first number is on the stack
4       % || 3 4 <    the second number is pushed onto the stack
add     % || 7 <      the ''add'' operator takes 2 numbers and pushes the sum onto the stack

In the Smalltalk implementation you do this with:

| ps |
ps := PostScript.Interpreter run: '3 4 add'.   "this returns an Interpreter"
ps pop                                         "returns the top element of the stack: 7"

There are no variables in PostScript, not even temporary ones. Instead, objects can be stores in a dictionary on the dictionary stack:

/seven { 3 4 add } def

This stores the procedure {3 4 add} under the name /seven in the top dictionary of the dictionary stack.

At the start of a PostScript interpreter, the dictionary stack contains 3 dictionaries:

  • user dict “empty dictionary for user defined entries”
  • global dict “globally accessible definitions. Initially empty”
  • system dict “bottom of the stack. Read only with build-in operators”
  • no global / local differenciation
  • no graphics operators
  • exception handling example

1)
PLRM.pdf PostScript Language Reference third edition
2)
PostScript Wikipedia article
3)
FORTH Wikipedia artickle
4)
Helitt-Packard Calulators Wikipedia article
5)
Reverse Polish Notation Wikipedia article
  • postscript.1581406423.txt.gz
  • Last modified: 2020/02/11 08:33
  • by christian