Path: utzoo!attcan!uunet!cs.utexas.edu!usc!samsung!munnari.oz.au!bruce!goanna!ok From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) Newsgroups: comp.lang.c Subject: Pascal (was Re: for(;;) vs. while(1) is a draw) Message-ID: <3104@goanna.cs.rmit.oz.au> Date: 30 May 90 07:23:04 GMT References: <5876@buengc.BU.EDU> <12955@smoke.BRL.MIL> <5879@buengc.BU.EDU> <1751@tkou02.enet.dec.com> Organization: Comp Sci, RMIT, Melbourne, Australia Lines: 35 In article <1751@tkou02.enet.dec.com>, diamond@tkou02.enet.dec.com (diamond@tkovoa) writes: : >Um, I've recently had a lot more contact with people from a Pascal : >background than I really wanted. Quickly now, what's wrong with this: : 1> program main; --------------------^ (output) should be declared because it is used! : 2> var i: integer; : 3> procedure p(n: integer); : 4> begin : 5> for i := 1 to n do write(' '); ------------------------^ the loop control variable must be LOCAL : 6> writeln(i); ----------------------------^ the loop control variable is now UNDEFINED : 7> end; : 8> begin : 9> p(10); :10> end. : >(I count three violations of the Pascal Standard.) : Then read the Pascal Standard and count again. There is one violation. Here are slightly edited error messages from a compiler: Line 5: FOR-loop control variable must be declared at this level Line 5: Standard file "output" must be declared by PROGRAM statement Line 6: Must assign value before using variable Line 6: Standard file "output" must be declared by PROGRAM statement : (Did you think that Pascal lacks a null statement?) No of course I didn't. I do hope that winning this argument helps to convince people that I'm right about the superiority of for (;;) over while (1) as well, but somehow I don't suppose it will. Too bad. -- "A 7th class of programs, correct in every way, is believed to exist by a few computer scientists. However, no example could be found to include here."