[444] in Coldmud discussion meeting

root meeting help first first in chain previous in chain previous next last

Re: "fixing" while loops

daemon@ATHENA.MIT.EDU (Fri Sep 23 14:40:40 1994 )

To: stewarta@netcom.com (Alex Stewart)
Cc: coldstuff@MIT.EDU
In-Reply-To: Your message of "Thu, 22 Sep 94 15:27:58 PDT."
Date: 	Fri, 23 Sep 1994 11:35:11 PDT
From: Erik Ostrom <ostrom@parc.xerox.com>

> while {statements} (testexpr) statement(s)

I think this would be bad for readability.

The cool thing about a while loop is that its meaning (usually) just jumps out 
at you:  For as long as this condition holds, do this other stuff.

Under this proposed syntax, you have  a word "while" which has a nice obvious 
meaning, and then you have a bunch of other stuff with no indication of what 
it's for (but it's not the test condition), and then something in parentheses, 
and then some more stuff in braces.

I think using "break" in mid-loop, as in Greg's example, makes clearer what's 
being tested and what the consequence of its result is.  The "while (1)" part 
looks a little silly, but I guess that's the price you pay for not wanting to 
clutter your language with keywords.

If you did end up doing something like this statements-test-statement 
construct, I'd recommend using a name other than "while", and keywords to 
indicate what's going on--maybe something like

  do {
    a = .test();
  } while (a) {

Okay, that's kind of broken, since we already expect "while" to be something 
different, and you may expect something from "do" as well.  I also think part 
of the problem with this is that you want all the pieces of the loop to be 
grouped together visually, and this looks too much like two or three separate 

Anyway.  Just random reaction.


PS. Oh, BTW, if you're looking for an assignment expression that people 
_really_ won't confuse with "==", you could use "<<".  It connotes transfer of 
RHS into LHS, and it doesn't look like equality at all.  Of course, C 
programmers will think it means bit shifting, sigh.