|
|
Darren New <dne### [at] sanrrcom> wrote:
> Warp wrote:
> > I disagree. I have been writing C++ for hobby and professionally for
> > over 10 years, and the total amount of C++ I have written is probably
> > closer to 100k lines of code. I don't remember *ever* writing even a
> > single "goto".
> Note that calling "return" in the middle of a function is equivalent to
> "goto". :-) Arguably "continue" and "break" and exceptions as well.
> Those are all non-structured constructs.
I really think that when Dijkstra wrote "goto considered harmful" he
really meant "goto", as in "jump to a label", and not other control
structures (such as returns, loops and conditionals).
The idea is that "goto" (ie "jump to a label") makes the code more
obfuscated than other control structures, and usually needlessly so.
> > It's not like I avoid it. I just don't need it. (Usually good basic
> > encapsulation takes automatically care of anything that would be an
> > "acceptable use of goto" otherwise.)
> Agreed. I was just trying to say that there are people who think "goto"
> is inherently evil, and that globals are inherently evil, because that's
> what they've been taught, but that's really just lies-to-children until
> they have enough experience to learn the few places where it really does
> make more sense.
I don't think goto is inherently evil. I think it's inherently unnecessary,
and overusing it is a bad idea. In the vast majority of cases there are
better alternatives.
> And then as programming languages evolve, they incorporate the good
> places to use a goto into the syntax of the language and call it
> something else, like "try/catch" or "return".
At least those state more clearly their intention and are not so easy
to misuse.
--
- Warp
Post a reply to this message
|
|