|
|
Log in / Subscribe / Register

Trivial, solved ages ago

Trivial, solved ages ago

Posted Jul 7, 2013 15:53 UTC (Sun) by HelloWorld (guest, #56129)
In reply to: Or even old loop constucts by mcmechanjw
Parent article: Philosophy and "for" loops — more from Go and Rust

We still have the loop and a half problem Knuth pointed out even in this article's examples...
No we don't, that problem was solved ages ago. In well-designed languages it's a non-issue because there's no pointless distinction between statements and expressions. Others, like GNU C, have features to cope with this kind of usage. In GNU C, your example
while(1) {
  statements
  if condition break;
  statements
}
can be rewritten as
while ({ statements; !condition; }) {
  statements
}
So, of course some people who choose to use outdated languages still have to worry about such paltry problems, but that certainly doesn't justify calling this an unsolved problem.


to post comments


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds