[comp.lang.pascal] How to make Berkeley Pascal explode.

djsalomon@watdragon.waterloo.edu (Daniel J. Salomon) (03/05/88)

While writing test programs for a compiler course, I came across this
Pascal program that sends Berkeley Pascal into a deep recursive sleep.
Running the version of Berkeley Pascal that came with 4.3 BSD on a
Microvax II, it took 420 CPU seconds to compile this program.  Adding
one more level of parentheses doubles the compile time.  Here is the
program:
--------------------------------------------------------------------
program nest (output);
var
    i, j, k : integer;
begin
    j:=5; i:=-5; k:=2;
    k := i+(j+(k+(i+(j+(k+(i+(j+(k+(i+(j+(k+(i+(j+(k+(i+(j+(k+i
	   )  )  )  )  )  )  )  )  )  )  )  )  )  )  )  )  );
    writeln (i, k);
end.

wsiebeck@rmi.UUCP (Wolfgang Siebeck) (03/10/88)

In this article Daniel J. Salomon writes:
: 
  [--]
: Running the version of Berkeley Pascal that came with 4.3 BSD on a
: Microvax II, it took 420 CPU seconds to compile this program.  Adding
: one more level of parentheses doubles the compile time.  Here is the
: program:
  [- 9 lines of Pascal source deleted -]

I tried TURBO-Pascal V 4.0 on your program. The test was run on a
Bullet-286ii, operating @ 7.7 MHz.


Turbo Pascal  Version 4.0  Copyright (c) 1987 Borland International
NEST.PAS(9)
9 lines, 0.1 seconds, 2320 bytes code, 591 bytes data.
	 ===========

The output of the program is:

-57

The resulting executable file has 2384 bytes.

Well, what should I say??