[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: The no goto religion
From:       James Richard Tyrer <tyrerj () acm ! org>
Date:       2007-07-31 12:52:07
Message-ID: 46AF3077.6010906 () acm ! org
[Download RAW message or body]

Fábio Firmo wrote:

> Maybe because I'm just a college kid that was teach by everyone that 
> goto's are evil, but in my few experiences in real projects I have 
> also faced some complicaded situations, and I never felt bad adding 
> one or two lines of redundant code or a new flag or adding extra exit
>  points. I know that sometimes my choices make the code a little less
>  efficient, but I know that in some months or years I'll understand 
> what I write without a second look at the code.

The extra code used to avoid using a "goto" can also be hard to understand.

> The same thing about my colleague, who probably was told to not use
> goto's too. The fact is that with my (very) limited knowlegde about
> the way that programmers code today, a non-go-to approach is much
> more common, and then when these coders read these lines, they'll
> say: "Hey, it's a little ugly, but I would do the same way".

It is true that very bad code can be written by using "goto"s.  Fortran
IV used "goto"s for control transfer.  You could write nice
structured code or you could write what is commonly called Spaghetti
code.  It is Spaghetti code which is evil, not the 'goto' statement.
OTOH, writing ugly code just to avoid using a "goto" of the purpose of
breaking out of nested structures is also evil.

Have you read:

http://www.ecn.purdue.edu/ParaMount/papers/rubin87goto.pdf

I think this clearly explains how the *limited* use of short range jumps
with "goto" can greatly improve code.

-- 
JRT
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic