Is break a normal or abrupt completion?
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
An abrupt completion always has an associated reason, which is one of the following:
A break with no label
A break with a given label
A continue with no label
A continue with a given label
A return with no value
A return with a given value
A throw with a given value, including exceptions thrown by the Java virtual machine
but later, talking about the for statement (14.14.1.2), it says
If the Expression is not present, then the only way a for statement can complete normally is by use of a break statement.
Is this incoherent or am I misunderstanding something?
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
It looks like you think that "abrupt completion" means "abnormal completion", as opposed to the words "complete normally" that you read about the for-statement. But I think that "abrupt completion" does not really mean "abnormal completion", and the statement that describes the for-statement doesn't directly have anything to do with the first description about abrupt completion. The statements are not contradicting each other, they are just talking about different things.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
14.1 Normal and Abrupt Completion of Statements
If all the steps are carried out as described, with no indication of abrupt completion, the statement is said to complete normally. (...)
There is also a section about the break statement, but tt is also obscure to me...
14.15 The break Statement
(...)
A break statement with no label attempts to transfer control to the innermost enclosing switch, while, do, or for statement of the immediately enclosing method or initializer block; this statement, which is called the break target, then immediately completes normally.
To be precise, a break statement with no label always completes abruptly, the reason being a break with no label. If no switch, while, do, or for statement in the immediately enclosing method, constructor or initializer encloses the break statement, a compile-time error occurs.
After rereading the chapter, I think that the break statement makes the body of the for statement (what is in parenthesis after the for(...) line ) complete abruptly, giving control to the for statement (or switch, while, do), which completes normally. Maybe an English native speaker understands it more clearly
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Federico Cardelle wrote:Maybe an English native speaker understands it more clearly
![]()
Maybe the keyword here is "speaker". The Java Language Specification, like all specifications, is written in a form of legalese. It can hardly be considered as written in the spoken form of english -- unless of course, you are a lawyer.
Henry
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
| You've gotta fight it! Don't give in! Read this tiny ad: Paul Wheaton's 16th Kickstarter: Gardening playing cards for gardeners and homesteaders https://coderanch.com/t/889615/Paul-Wheaton-Kickstarter-Gardening-playing |








