Re: what does two semicolns ';;' do
- From: Tim Streater <tim.streater@xxxxxxxxxxxx>
- Date: Mon, 30 Jun 2008 13:54:18 +0100
In article <g4kh6453kqnfu1lddaee4qi6407mkovt76@xxxxxxx>,
Michael Fesser <netizen@xxxxxx> 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.
Here's some code from a simple app I am working on:
foreach ($attstrs as $nextatt)
{
if ($nextatt=='') continue;
$nextatt = "/Volumes/" . str_replace (":", "/", $nextatt);
$handle2 = fopen ($nextatt, "rb");
if ($handle2===false)
{
echo "Error - could not open attachment:\n '" . $nextatt .
"'\n";
continue;
}
...
}
Two continues in there. The alternative is to nest the code deeper,
something I avoid like the plague.
.
- References:
- what does two semicolns ';;' do
- From: larry
- Re: what does two semicolns ';;' do
- From: AnrDaemon
- Re: what does two semicolns ';;' do
- From: Michael Fesser
- Re: what does two semicolns ';;' do
- From: Tim Streater
- Re: what does two semicolns ';;' do
- From: Michael Fesser
- what does two semicolns ';;' do
- Prev by Date: Re: what does two semicolns ';;' do
- Next by Date: Re: lookup funcion
- Previous by thread: Re: what does two semicolns ';;' do
- Next by thread: XAMMP on OpenSuse
- Index(es):
Relevant Pages
|