Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!zephyr.ens.tek.com!tektronix!nosun!qiclab!m2xenix!puddle!p15.f42.n105.z1.fidonet.org!Jim.Long From: Jim.Long@p15.f42.n105.z1.fidonet.org (Jim Long) Newsgroups: comp.lang.modula2 Subject: Re: Why are the loops so awkward? Message-ID: <5760.26782571@puddle.fidonet.org> Date: 14 Jun 90 19:56:36 GMT Sender: ufgate@puddle.fidonet.org (newsout1.26) Organization: FidoNet node 1:105/42.15 - Bink of an Aye, Portland OR Lines: 23 In a message of <14 Jun 90 17:07:42>, cspw quagga (5:494/4) writes: >There have been a number of suggestions that my awkward problem >of processing every element in a string should be coded >like this > i := 0; > WHILE (i < Length(s)) DO > process(S[i]); > INC(i); > END; > >Although this works nicely, it violates all the ideas that one >should distinguish between definite loops (where the number of iterations >is known in advance, and a FOR loop is the most appropriate >construct), and an indefinite loop where one iterates until or while >the conditions have not been fulfilled. Without seeing the definition of 'process(CHAR)' we cannot determine from this code fragment which type of loop we have. If S[i] is passed as a VAR CHAR, the loop may be indefinite. -- uucp: uunet!m2xenix!puddle!42.15!Jim.Long Internet: Jim.Long@p15.f42.n105.z1.fidonet.org