Wes Groleau wrote:
[ ... ]
Interesting. Ada is bad because you _think_ it won't let you do what
you want to do.
First of all, I've never said Ada was bad -- at worst, I've said that I
found some things about it frustrating. Second, my opinions are based
on use, not just what I think might be true about it. Finally, I've
openly admitted that some (pehaps all) of my opinions may be obsolete
since my experience predates Ada 95.
But it would be better if it prevented other people
from doing something you think they shouldn't do.
It's been close to 10 years now that Java has had its multi-level
break, and in that time I'm not at all certain I've seen even _one_
instance of its use that wouldn't have been better off without it.
In the end, designing a (good) programming language requires a lot of
judgement calls, not simply applying some simplistic rule like "allow
everything". A theoretically ideal programming language would allow
everything that was intended and desired, but stop everything that
wasn't.
Real languages deal in compromises -- one is that permitting more of
what people want to do also generally allows more things they didn't
really want to do.
I think this "feature" has an even greater cost though. While most
people recognize that the undisguised goto is something to generally
avoid, many (especially those too young to have dealt with FORTRAN II
computed gotos) rarely consciously realize that a break (of any sort)
is simply a restricted form of a goto -- and the less restricted it is,
the more it's just a goto by a different name.
The result is that when people are faced with using a goto to exit from
a deeply nested loop, they usually have second thoughts -- and with a
little more thought, realize that the code can be re-structured to
eliminate the real problem that led them to want to do that in the
first place.
OTOH, when that goto is disguised as a "multi-level break", it appears
(at least to me) that they're much more willing to just use the
goto^H^H^H^Hmulti-level break instead of fixing the code.
In fairness, the multi-level goto is marginally more justifiable in
Java than in Ada -- Java copied all of C's biggest mistakes, including
its screwed up switch/case statement. It's quite often useful to have a
switch statement in a loop, and exit the loop as one of the legs of the
switch -- but the screwed-up switch makes this a multi-level break.
Regardless of other shortcomings I might see in its design, Ada did get
its case statement right, so a single-level break suffices for this
situation.