Erik Naggum <····@naggum.net> writes:
> (I think this is a serious design mistake in those languages
> because it means that you can only put the termination condition
> in one place.)
I don't know if I'd go that far. `while' is extremely general as-is.
For example, a simple while() statement in C can do everything a for()
can do. For example:
int i;
for(i=0;i<10;i++) {
body(i);
}
is equivalent to:
int i=0;
while (i<10) {
body(i);
i++;
}
(or something like that).
I don't think I'd mind having WHILE as a macro in the CL package.
dave
David Bakhash <·····@alum.mit.edu> writes:
> Erik Naggum <····@naggum.net> writes:
>
> > (I think this is a serious design mistake in those languages
> > because it means that you can only put the termination condition
> > in one place.)
>
> I don't know if I'd go that far. `while' is extremely general as-is.
> For example, a simple while() statement in C can do everything a for()
> can do. For example:
>
> int i;
> for(i=0;i<10;i++) {
> body(i);
> }
>
> is equivalent to:
>
> int i=0;
> while (i<10) {
> body(i);
> i++;
> }
>
> (or something like that).
>
> I don't think I'd mind having WHILE as a macro in the CL package.
the problem with "while" and "for" are that many times it makes sense
to break out in the middle of the loop. i don't know how many times
i've written
while (1)
{
...do stuff...
if (done) break;
...do more stuff...
}
i probably use that more than i use a while with a conditional as an
argument. (yes, i know "for(;;)" is the canonical form for this, but
any reasonable optimizing compiler makes them the same.)
if you don't like the full-blown LOOP style, you can always use a
simple LOOP and then RETURN out of it.
(loop
(do-stuff-1)
(when (done) (return))
(do-stuff-2))
do-stuff-1 and do-stuff-2 being null are just special cases.
--
J o h a n K u l l s t a m
[········@ne.mediaone.net]
Don't Fear the Penguin!