Alternative to "while" loop
<p>I'm looking for a better alternative to following code. Assume some of the usual programming languages (C/C++, java, ...):</p>

<p>1)</p>

<pre><code>while( true ) {
  foo = ... something ugly ...
  if( foo == null ) break;
  ... some code
}
</code></pre>

<p>not nice because uses a loop for ever and a break that could became "lost" in the middle of some code.</p>

<p>2)</p>

<pre><code>foo = ... something ugly ...
while( foo != null ) {
  ... some code
  foo = ... something ugly ...
}
</code></pre>

<p>not nice because assignment to "foo" is duplicated. Same in this case:</p>

<p>2b)</p>

<pre><code>for( foo = ... something ugly ...; 
     foo != null;
     foo = ... something ugly ... ) {
  ... some code
}
</code></pre>

<p>3)</p>

<pre><code>goto INIT:
while( foo != null ) {
  ... some code
  INIT: foo = ... something ugly ...
}
</code></pre>

<p>"goto" to the middle of one loop.</p>

<p>4)</p>

<pre><code>do {
  foo = ... something ugly ...
  if( foo != null ) {
     ... some code 
  }
} while ( foo != null )
</code></pre>

<p>condition is duplicated.</p>

<p>It seems strange something so common has no good implementation.</p>