Loop iterator - example.txt

Derek Parnell derek at psych.ward
Sun Apr 30 15:49:46 PDT 2006


On Mon, 01 May 2006 06:08:53 +1000, Unknown W. Brackets  
<unknown at simplemachines.org> 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?

The use of 'goto' has an inherinent cost in terms of ongoing maintenance  
of code. In short, it adds to the time it takes to analyse code prior to  
making changes that do not have unintended side-effects. That cost must be  
justifed. Therefore one should only use 'goto' in situation in which the  
cost of its use can be offset by some other gain in the code. Such a gain  
is performance in a performace-critical section of code. I'm not sure if  
there are any other situations it is cost-justified.

-- 
Derek Parnell
Melbourne, Australia



More information about the Digitalmars-d mailing list