[455] in Coldmud discussion meeting

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

while, where, when, with -- WHAT?!

daemon@ATHENA.MIT.EDU (Sat Sep 24 23:07:42 1994 )

Date: Sat, 24 Sep 1994 23:04:02 -0400 (EDT)
From: James C Deikun <jcdst10+@pitt.edu>
To: coldstuff@MIT.EDU
In-Reply-To: <9409241522.AA07300@glacier.mit.edu>



On Sat, 24 Sep 1994, Greg Hudson wrote:

> 
> I'd just like to throw a few more ideas into the mix:
> 
> This reads as, "while [go off and set the value of a to .test()] a
> isn't negative, do something with a".  This is a rather disjointed
> sentence; there are ways of reading this that make grammatical sense
> (e.g. "while the value of .test(), which I'll call a, is nonegative,
> do something with a"), but they don't come directly from reading the
> code (when := is your generic assignment operator) and gloss over the
> side-effect, which is exactly how you see people writing C expressions
> a lot.

Personally, I don't see a problem with side effects as such.  Unexpected 
side effects are the only real problem (which is why := beats =).
 
[etc]
> If while() isn't the appropriate construct, let's try C's for() (which
> I realize doesn't exist in Coldmud):
> 
> 	for (a = .test(); a >= 0; a = .test())
> 		.do_something(a);

C's for is definitely NOT something I'd like to see imported into 
ColdMUD.  It's far and away the least intuitive statement in the language 
and best left where it is.

[...]
> loop until a is nonnegative, doing something with a."  Consider:
> 
> 	where (a = .test(); a >= 0)
> 		.do_something(a);
> 
> The name "where" is the best I could come up with on short notice, and
> of course any name for a new looping construct is going to sound a bit
> funny ("for (a;b;c)" is not particularly intuitive; while (a)" is
> easily made intuitive mainly because it's so simple).  This construct
> takes care of all of the situations for which people want assignment
> expressions in while loops.  I argue that a when loop is more
> intuitive than a while loop with a side-effect in the condition.

Where or when or whatever, this introduces needless complication to the 
language.  It might be argued that a complicated language is better than 
complicated code, but then you don't need a reference book to decipher a 
complicated expression, just a bit of head-scratching, as opposed to the 
case of an unfamiliar construct.

Besides, I don't see how this would take care of multiple assignments in 
the condition.

[ifs with assignment]
> If we think of where() as a while() with a preparatory statement
> clause, then we might try to apply the same solution here, but this
> requires making up yet another name and complicating your control flow
> constructs again.

All I can say is, ick.
  
>                    Assignment expressions are another solution (with
> associated defects), and ignoring the problem is also acceptable
> (really, I don't use assignment expressions in C, and these things
> don't bother me too much).

Assignment expressions, yes, are acceptable, but ignoring the problem 
often requires 132-column display capabilites.

> 
> However, let me throw out just one more crazy idea: leave looping
> alone for now and extend the expression syntax:
> 
> 	(where IDENT := expr) expr
> 
> For example:
> 
> 	while ((where a := .test()) a >= 0)
> 		.do_something(a);

To me, it seems like you've just reinvented assignment expressions while 
complicating the syntax.

A crazy idea of my own:  maybe it'd be best to end the language wars once 
and for all by introducing low-level code access and writing the compiler 
in the DB.  From my inspection of the server code, ColdMUD's string 
operations seem efficient enough for this, unlike those of L-----M--.  
One could even use a buffer and decomplicate the structure considerably.

This way, if you don't like the language, you could conceivably modify or 
replace it.  If you get crazy with this, it could get confusing, but then 
noone will program anything cool at your site and you get what you 
deserve.  :)