Reputation: 6008
I recently read about labelled statments in java and the ability to specify a label with the break and continue statements. What other languages support this sort of syntax ?
Upvotes: 8
Views: 1098
Reputation: 40150
Do you wan an exhaustive list? How are you going to award the answer? To whomever lists most?
Basic, Pascal, Perl, all assemblers, I woudl imaigine (do I get a point for each that I name?, ...
You might want to read
http://en.wikipedia.org/wiki/Goto
http://en.wikipedia.org/wiki/Unstructured_programming
http://en.wikipedia.org/wiki/Considered_harmful
Upvotes: 0
Reputation: 718826
Here's a list of languages with Java-like labels; i.e the ability to branch out of a labeled statement or block.
goto <label>
, but not break <label>
or continue <label>
.exit <label>
statement.exit <label>
or continue <label>
statements.Here's a list of languages with a more general GO TO construct (or equivalent), allowing an application to branch to any label at the same syntactic level or outer level.
Many languages (also) support throwing and catching exceptions. This can be thought of as a generalized form of branch-to-label. However there are two important distinctions:
(Ruby's throw / catch
seems to have aspects of normal exception handling and labeled statements. However, I'm inclined to think that since the label does not need to be lexically scoped, this is closest to normal exception handling.)
please add more.
Upvotes: 5
Reputation: 55
Upvotes: 0