From help-octave-request at bevo dot che dot wisc dot edu Fri Jan 28 17:03:00 2000 Subject: Re: Suggestion: add do-enddo(condition) From: "Johan Kullstam" To: help-octave at bevo dot che dot wisc dot edu Date: 28 Jan 2000 18:03:19 -0500 (Ted Harding) writes: > I would be in favour of introducing these forms, > > (a) for convenience, > > (b) because "built-in" implementation would normally be much faster > than interpretation of the above implementations. > > However, I suggest it might be better to do the test _before_ executing > the body -- i.e. if the loop is entered with its exit condition already > true, then the body would not be executed -- for both 'while' > and 'until' (since either way round 'until' == 'while not'). we *already have* a looper that tests before executing. while cond body endwhile. what we *don't* have (yet) is the other one --- execute at least once before test. do body while cond or do body until cond. > This would be consistent with the behaviour of the C 'while (cond) body' > construct, which does it this way (as opposed to the C construct > 'do body while (cond)' which tests the condition after executing the > body). The difference is that with the post-test the body is executed > at least once; with the pre-test it might not be executed at all. > > There are arguments for the merits of either way round, but I think > that the pre-test form is likely to be the one most often useful. oh most certainly. the pre-test will probably remain the most popular form. however, the post-test form is surely useful too and should be added. -- J o h a n K u l l s t a m [kullstam at ne dot mediaone dot net] Don't Fear the Penguin! ----------------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.che.wisc.edu/octave/octave.html How to fund new projects: http://www.che.wisc.edu/octave/funding.html Subscription information: http://www.che.wisc.edu/octave/archive.html -----------------------------------------------------------------------