Why does the instruction "do" require a "while"?
- by 909 Niklas
Since this statement is so common:
while (true) (Java)
or
while (1) (C)
or sometimes
for (;;)
Why is there not a single instruction for this? I could think that an instruction that could do it is just do but do requires a while at the end of the block but it would be more logical to write an infinite loop like this
do {
//loop forever
}
Why not? AFAIK the instruction do always requires a while at the end but if we could use it like above then it would be a clear way to define something like while (true) which I think should not be written like that (or for (;;)).