[net.lang.pascal] Berkeley Pascal grinds to a halt.

cs444@watrose.UUCP (Course Account) (04/20/86)

While writing test programs for some student compilers, I found
a very short Pascal that makes the Berkeley Pascal get stuck in
its tracks.  Here it is:

    program main (output);
    var
	i, k : integer;
    begin
	i := 1;
	k := i+(i+(i+(i+(i+(i+(i+(i+(i+(i+(i+(i+(i+(i+(i+(i+(i+(i+i
		)))))))))))))))));
	writeln (i, k);
    end.

This program takes over 400 seconds to compile on a VAX-11/780.
The time it takes doubles with each nested addition appended to the
expression.  Thus pc's running time is exponential for expressions of
this sort.

Conclusion: If your compiles have been taking a long time, see if you
can reduce the nesting of parentheses.

koch@unido.UUCP (05/02/86)

on our vax 11/750 it is the same phenomene.
but the program is executed very fast.
miko, unido

cs444@watrose.UUCP (Course Account) (05/07/86)

The times given were for Berkeley 4.2 UNIX.
Apparently the problem has been corrected in 4.3.