POV-Ray : Newsgroups : povray.pov4.discussion.general : Next Generation SDL Brainstorming : Re: Next Generation SDL Brainstorming Server Time
14 May 2024 21:40:57 EDT (-0400)
  Re: Next Generation SDL Brainstorming  
From: clipka
Date: 27 Mar 2009 12:55:00
Message: <web.49cd0462ad594047208afb30@news.povray.org>
"Kenneth" <kdw### [at] earthlinknet> wrote:
> My main concern is actually with 'semantics' (if that's the right word.) I.e.,
> the term #while seems to be quite logical and understandable in its meaning:

Actually, I remember that when I started programming, I was multiple times
fooled by the while-loop, about when the condition is checked. The most
intuitive loop, for me, was:

REPEAT
  ...
UNTIL (condition);

which did exactly what I always expected it to do: Execute the list of
statements, *then* check for the condition, and if it didn't hold true, repeat
the whole smash over and over again.

Then again, maybe this is still not the most intuitive, as there might be some
confusion whether the statements are executed if the condition doesn't hold
true right from the start, so maybe this would be the clearest (albeit not the
most elegant):

REPEAT {
  ...
  IF (condition) END REPEAT
  ...
}

Note that you can build *any* type of loop from this:

// while(condition) ...:
REPEAT {
  IF (NOT condition) END REPEAT
  ...
}

// repeat ... until(condition):
REPEAT {
  ...
  IF (condition) END REPEAT
}

// for i from 1 to n:
LET i = 1
REPEAT {
  IF (i > n) END REPEAT
  ...
}


BTW, as another alternative for the for-loop, how about this:

REPEAT COUNTING i FROM 1 TO n {
  ...
}

I guess that should be plain enough. Otherwise I give up ;)


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.