[433] in Coldmud discussion meeting

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

Re: "fixing" while loops

daemon@ATHENA.MIT.EDU (Thu Sep 22 18:02:19 1994 )

To: deforest@netcom.com (Robert de Forest)
Cc: coldstuff@MIT.EDU
In-Reply-To: Your message of "Thu, 22 Sep 1994 10:47:12 PDT."
             <199409221747.KAA23309@netcom14.netcom.com> 
Date: Thu, 22 Sep 1994 17:58:59 -0400
From: Greg Hudson <ghudson@MIT.EDU>


Okay, some notes:

(1) On atomic: my plan was to have methods be atomic by default, allow
a method to be declared "non_atomic", and introduce the keyword
"atomic" which could be used to modify statements.

Once you enter an atomic block, you cannot suspend or be preempted
until you leave the atomic block.

I'm not sure this is the right idea; in particular, it prevents people
from using suspend() except when they allow themselves to be preempted
at any time.

(2) On philosophy: two points I followed while I was development
Coldmud were simplicity of interface (which is not the same as
simplicity of implementation) and enforced uniformity of programming
style--specifically, vertical organization of code.  Assignment is a
statement because I don't like seeing assignments used as expressions.
If the current maintainer doesn't mind seeing assignments used as
expressions, perhaps that requirement should be relaxed.

It seems like this issue focuses on the while loop.  I usually rewrite

	while (a = .test())
	    .do_something()

as

	while (1) {
	    a = .test();
	    if (!a)
		break;
	    .do_something();
	}

The number of lines doesn't bother me very much.  If people are really
worried by an extra four lines of code for a fairly uncommon
construct, something like what Robert proposed could make it a
non-problem.