Re: what does two semicolns ';;' do



Michael Fesser wrote:
.oO(Tim Streater)

In article <ivgh64ll18rvnv95q6noc13cadab4r17uh@xxxxxxx>,
Michael Fesser <netizen@xxxxxx> wrote:

Pest or cholera. You also have to use a break to leave the while loop.
IMHO infinite loops are always ugly and bad coding style, regardless of
how you code them.
Not necessarily. I would always use while (true), as then you make explicit what you are doing. Secondly, sure you have to break out of the loop. But suppose there's a number of different reasons to do so? You're not necessarily going to be able to choose one as the "main driver" of the loop, which ought then to migrate into the loop construct?

You could still find a better way to express the loop condition, even if
it's just a variable:

while (!$workIsDone) {
...
}

I admit that I also use break/continue from time to time, but I try to
avoid them because they often lead to hard to understand spaghetti code.
There's almost always a better way to structure the code.

Micha

I agree. I never use while(true) or while(1), but opt for the
while ($somecondition) when I have to do this. That way there is an explicit test at the top of the loop and I don't have to use "break". I feel that the code is more readable if you can tell right away where the next line is.
.



Relevant Pages

  • Re: what does two semicolns ;; do
    ... Michael Fesser wrote: ... sure you have to break out of the loop. ... Good programmers write clean code, not code that is 0.01% faster, but clean code. ... It is a horror to read over code written by would-be programmers that is aimed at speed, or people trying to keep the sourcefiles as small as possible. ...
    (comp.lang.php)
  • Re: Question on conditional statements
    ... Michael Fesser wrote: ... >>When running through a loop, how can you test two separate conditions ... >>against the same $element of an array. ...
    (comp.lang.php)
  • Re: something like grep
    ... Michael Fesser wrote: ... tree. ... to loop through a directory and all that's beneath it if necessary. ...
    (comp.lang.php)
  • Re: what does two semicolns ;; do
    ... Michael Fesser wrote: ... IMHO infinite loops are always ugly and bad coding style, regardless of ... the loop, which ought then to migrate into the loop construct? ... avoid them because they often lead to hard to understand spaghetti code. ...
    (comp.lang.php)
  • Re: Race condition in mb_free_ext()?
    ... Your suggestion will always enter the loop and do the atomic ... Regardless, though, the livelock itself, assuming it ... (before the 'dofree' variable was introduced there). ...
    (freebsd-net)