Groovy Language Specification  
First Draft  
Chapter 14

Blocks and Statements

The organization of this chapter parallels the chapter on Blocks and Statements in the Java Language Specification (second edition), which begins as follows:
The sequence of execution of a program is controlled by statements, which are executed for their effect and do not have values.
Some statements contain other statements as part of their structure; such other statements are substatements of the statement. We say that statement S immediately contains statement U if there is no statement T different from S and U such that S contains T and T contains U. In the same manner, some statements contain expressions (§15, JLS) as part of their structure.
The first section of this chapter discusses the distinction between normal and abrupt completion of statements (§14.1, JLS). Most of the remaining sections explain the various kinds of statements, describing in detail both their normal behavior and any special treatment of abrupt completion.
Blocks are explained first (§14.2, JLS), followed by local class declarations (§14.3, JLS) and local variable declaration statements (§14.4, JLS).
Next a grammatical maneuver that sidesteps the familiar "dangling else" problem (§14.5, JLS) is explained.
Statements that will be familiar to C and C++ programmers are the empty (§14.6, JLS), labeled (§14.7, JLS), expression (§14.8, JLS), if (§14.9, JLS), switch (§14.10, JLS), while (§14.11, JLS), do (§14.12, JLS), for (§14.13, JLS), break (§14.14, JLS), continue (§14.15, JLS), and return (§14.16, JLS) statements.
Unlike C and C++, the Java programming language has no goto statement. However, the break and continue statements are allowed to mention statement labels.
The Java programming language statements that are not in the C language are the throw (§14.17, JLS), synchronized (§14.18, JLS), and try (§14.19, JLS) statements.
The last section (§14.20, JLS) of this chapter addresses the requirement that every statement be reachable in a certain technical sense.

14.1 Normal and Abrupt Completion of Statements

(Cf. JLS. §14.1.)

TO DO

14.2 Blocks

(Cf. JLS. §14.2.)

TO DO

14.3 Local Class Declarations

(Cf. JLS. §14.3.)

TO DO

14.4 Local Variable Declaration Statements

(Cf. JLS. §14.4.)

TO DO

14.4.1 Local Variable Declarators and Types

(Cf. JLS. §14.4.1.)

TO DO

14.4.2 Scope of Local Variable Declarations

(Cf. JLS. §14.4.2.)

TO DO

14.4.3 Shadowing of Names by Local Variables

(Cf. JLS. §14.4.3.)

TO DO

14.4.4 Execution of Local Variable Declarations

(Cf. JLS. §14.4.4.)

TO DO

14.5 Statements

(Cf. JLS. §14.5.)

TO DO

14.6 The Empty Statement

(Cf. JLS. §14.6.)

TO DO

14.7 Labeled Statements

(Cf. JLS. §14.7.)

TO DO

14.8 Expression Statements

(Cf. JLS. §14.8.)

TO DO

14.9 The <code>if Statement</h2>

(Cf. JLS. §14.9.)

TO DO

14.9.1 The <code>if-then Statement</h3>

(Cf. JLS. §14.9.1.)

TO DO

14.9.2 The <code>if-then-else Statement</h3>

(Cf. JLS. §14.9.2.)

TO DO

14.10 The <code>switch Statement</h2>

(Cf. JLS. §14.10.)

TO DO

14.11 The while Statement

(Cf. JLS. §14.11.)

TO DO

14.11.1 Abrupt Completion

(Cf. JLS. §14.11.1.)

TO DO

14.12 The do Statement

(Cf. JLS. §14.12.)

TO DO

14.12.1 Abrupt Completion

(Cf. JLS. §14.12.1.)

TO DO

14.12.2 Example of do statement

(Cf. JLS. §14.12.2.)

TO DO

14.13 The <code>for Statement</h2>

(Cf. JLS. §14.13.)

TO DO

14.13.1 Initialization of <code>for statement</h3>

(Cf. JLS. §14.13.1.)

TO DO

14.13.2 Iteration of for statement

(Cf. JLS. §14.13.2.)

TO DO

14.13.3 Abrupt Completion of <code>for statement</h3>

(Cf. JLS. §14.13.3.)

TO DO

14.14 The <code>break Statement</h2>

(Cf. JLS. §14.14.)

TO DO

14.15 The <code>continue Statement</h2>

(Cf. JLS. §14.15.)

TO DO

14.16 The <code>return Statement</h2>

(Cf. JLS. §14.16.)

TO DO

14.17 The <code>throw Statement</h2>

(Cf. JLS. §14.17.)

TO DO

14.18 The <code>synchronized Statement</h2>

(Cf. JLS. §14.18.)

TO DO

14.19 The <code>try statement</h2>

(Cf. JLS. §14.19.)

TO DO

14.19.1 Execution of try-catch<code><b></code></h3>

(Cf. JLS. §14.19.1.)

TO DO

14.19.2 Execution of try-catch-finally<code><b></code></h3>

(Cf. JLS. §14.19.2.)

TO DO

14.20 Unreachable Statements

(Cf. JLS. §14.20.)

TO DO


Specification Table of Contents.

The organization of this chapter parallels the chapter on Blocks and Statements in the Java Language Specification (second edition).

The original of this specification is at http://docs.codehaus.org/display/GroovyJSR.