Loop iterator - example.txt

Alexander Panek alexander.panek at brainsware.org
Sun Apr 30 15:21:29 PDT 2006


Unknown W. Brackets wrote:
> At the risk of asking a stupid question, what is wrong with gotos?
> 
> I realize they can result in code that people with insufficient 
> programming experience might not understand (and I'm not trying to be 
> arrogant here, because I avoid using gotos for exactly and only this 
> reason, I don't use or read them enough.)
> 
> But that doesn't seem reason enough for everyone to hate them.  If I see 
> a need for one, I use it - and I add comments to make sure no one gets 
> confused.
> 
> Is the only reason that people fear them, or is there a real legitimate 
> reason?
> 
> -[Unknown]
> 
> 
>> How about we all try to avoid GOTOs and you implement this keyword? :P
>>
>> Regards,
>> Alexander Panek

I *do* understand them, and I also do know, that they are useful and 
whatnot. Still, I don't like them - they are a relict of early C times. 
But now we've got neat, mighty conditional loops - what do we need GOTOs 
for?

A friend of mine once wrote such code:

<code>
label:
doSomething( );

if ( condition )
	goto label;
</code>

That *is* a do-while loop.

<code>
do {
	doSomething( );
} while ( condition )
</code>

Effectively, those two construct are the same, but the second one is, 
IMO, far better readable (readable as in recognization of what a program 
is doing).

Regards,
Alexander Panek



More information about the Digitalmars-d mailing list