P
Paul Lutus
Christopher said:Paul Lutus said:Christopher Barber wrote:
/ ...
The reason I hate to tell you this is because it [ goto, break ] is always a bad
programming idea.
Nonesense! What's wrong with labeled break/continue? Can you explain
exactly what kind of bad things can happen if you use it?
It creates terrible, impossible-to-maintain code. It violates every
precept of structured programming.
You have to do better than that.
I can't believe this classic case needs to be restated.
http://www.acm.org/classics/oct95/
http://cs-exhibitions.uni-klu.ac.at/contentStrucProgr.php
http://acweb.colum.edu/users/rcourington/Progclass/struprog.html
Ad infinitum.
You are simply reasserting that it is
bad
without providing details. In my own experience with these features, it
usually leads to clearer code.
Unrestricted 'goto' as in C or BASIC is indeed rare in new languages, but
constrained forms such as labeled 'break' and 'continue' continue to be
included in new languages.
IMHO only as a crutch for those not fully capable of structured programming.
In Java at least, a labelled "break" or "continue" must refer to an
enclosing labelled scope, not an arbitrary label located anywhere. This is
an improvement, but since any program can be written without these devices,
and since the consensus seems to be that these devices undermine structured
programming, I think in time they will disappear, as goto is disappearing.
C# even introdued an actual 'goto' that lets
you
jump to labels within a switch statement. These features were designed
after careful consideration by experienced programmers and language
designers.
"Experienced" is a non sequitur, it can mean anything (streetwalkers are
experienced). As you can see by reading the above articles, one will find
it difficult to defend this inclusion. IMHO this device was included to
avoid alienating too many legacy programmers. It was most certainly not
included to increase the degree to which C# represents the best in
structured programming.