🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.pascal
Article #286

Berkeley Pascal grinds to a halt.

#286
From: Course Account
Date: Sun, 20 Apr 1986 01:01
22 lines
1199 bytes
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.
Technical Details
Message-ID: <8004@watrose.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!watmath!watnot!watrose!cs444

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/18/84; site watrose.UUCP
Path: arc1-ca.pugleaf.net!utzoo!watmath!watnot!watrose!cs444
From: cs444@watrose.UUCP (Course Account)
Newsgroups: net.lang.pascal
Subject: Berkeley Pascal grinds to a halt.
Message-ID: <8004@watrose.UUCP>
Date: Sat, 19-Apr-86 20:01:54 EST
Article-I.D.: watrose.8004
Posted: Sat Apr 19 20:01:54 1986
Date-Received: Sun, 20-Apr-86 18:04:13 EST
Distribution: net
Organization: U of Waterloo, Ontario
Lines: 22