"para" C pretty-printer (C/UNIX history/trivia)

Mike Tilson mike at hcradm.UUCP
Tue Apr 30 11:32:01 AEST 1985


Geoff Collyer at the University of Toronto recently mentioned the "para"
C formatting program I wrote for V6 UNIX.  This brought back some
memories that you might find amusing.

"Para" was designed to almost completely ignore the user's original
formatting.  The reason for this is interesting:  It was part of a *batch*
computer graphics system that read C programs from *punched cards*!!!
(For you youngsters:  You can see card punches in the new Computer Museum
in Boston, along with the Sage computer and other goodies.)  The program
was then listed on a printer, and the graphics output came out on a
low cost pen plotter.  The whole thing ran on a PDP-11/40 with RK05 disks
running fairly vanilla UNIX V6.  (The kernel was modified to enforce
resource limits and to make sure you couldn't execute any of a number of
system calls, for protection purposes.)  Core dumps produced formatted
listings of variables -- the compiler was modified to produce program
line numbers in the symbol table and *para* produced the variable symbol
table to allow the dump routine to interpret the dump!  (This was a byproduct
of the fact that it also did pretty complete syntax and semantic checking
of the program, including enforcement of more stringent type rules
similar to "lint", which did not exist at the time.  We wanted more
"user-friendly" error handling, and as much as possible all program errors
were handled by this phase.  Also, the machine was too loaded and most student
programs have errors, so we tried to catch everything in "pass 1" and avoid
the expensive "cc" pass.)

The entire thing was a monument to low budgets (CRT's cost too much, and
the system could only run a UNIX shift a few hours per day) and to low cost
student labor.  The only CRT associated with the system was the name:
CRT Batch System.  In this context "CRT" stood for "Crossey-Reeves-Tilson",
the implementors of this creature.

In any case, the punch card format made it mandatory to provide a
prettyprinter -- you couldn't ask the user to re-punch 100 cards in
order to add indenting if you changed a loop.  "Para" had some nice
features -- it understood macros, so that

	#define cycle 	for(;;) {
	#define next	}

	cycle
		foo();
		if(bar())
			break;
		foobar();
	next

indented properly.  (The above is an example -- no remarks on whether you
would write such a program, please.)  It also handled "else if" in a
reasonable way, and it allowed for block comments in the form
	/*
	 * comment, note the stars line up
	 * like this
	 */

There are a lot of things I would do differently today (like not do it
at all) but it was great experience nine years ago, and we spent a fun summer
building the system (including spoolers, multiple batch initiators,
comprehensive job cost accounting, resource controls, operator controls, etc.)
The system saw production use for several years thereafter, much to the
dismay of the students who had to use it.

/Michael Tilson, Human Computing Resources Corp. {utzoo,decvax}!hcr!hcradm!mike



More information about the Comp.lang.c mailing list