Add a more functional (i.e. fewer-stubs) implementation of System.Data.Linq.
[mono.git] / mcs / docs / ecma334 / 15.8.3.xml
1 <?xml version="1.0"?>
2 <clause number="15.8.3" title="The for statement">
3   <paragraph>The for statement evaluates a sequence of initialization expressions and then, while a condition is true, repeatedly executes an embedded statement and evaluates a sequence of iteration expressions. <grammar_production><name><non_terminal where="15.8.3">for-statement</non_terminal></name> : <rhs><keyword>for</keyword><terminal>(</terminal><non_terminal where="15.8.3">for-initializer</non_terminal><opt/><terminal>;</terminal><non_terminal where="15.8.3">for-condition</non_terminal><opt/><terminal>;</terminal><non_terminal where="15.8.3">for-iterator</non_terminal><opt/><terminal>)</terminal><non_terminal where="15">embedded-statement</non_terminal></rhs></grammar_production><grammar_production><name><non_terminal where="15.8.3">for-initializer</non_terminal></name> : <rhs><non_terminal where="15.5.1">local-variable-declaration</non_terminal></rhs><rhs><non_terminal where="15.8.3">statement-expression-list</non_terminal></rhs></grammar_production><grammar_production><name><non_terminal where="15.8.3">for-condition</non_terminal></name> : <rhs><non_terminal where="15.7.1">boolean-expression</non_terminal></rhs></grammar_production><grammar_production><name><non_terminal where="15.8.3">for-iterator</non_terminal></name> : <rhs><non_terminal where="15.8.3">statement-expression-list</non_terminal></rhs></grammar_production><grammar_production><name><non_terminal where="15.8.3">statement-expression-list</non_terminal></name> : <rhs><non_terminal where="15.6">statement-expression</non_terminal></rhs><rhs><non_terminal where="15.8.3">statement-expression-list</non_terminal><terminal>,</terminal><non_terminal where="15.6">statement-expression</non_terminal></rhs></grammar_production></paragraph>
4   <paragraph>The <non_terminal where="15.8.3">for-initializer</non_terminal>, if present, consists of either a <non_terminal where="15.5.1">local-variable-declaration</non_terminal> (<hyperlink>15.5.1</hyperlink>) or a list of  <non_terminal where="15.6">statement-expression</non_terminal>s (<hyperlink>15.6</hyperlink>) separated by commas. The scope of a local variable declared by a <non_terminal where="15.8.3">for-initializer</non_terminal> starts at the <non_terminal where="15.5.1">local-variable-declarator</non_terminal> for the variable and extends to the end of the embedded statement. The scope includes the <non_terminal where="15.8.3">for-condition</non_terminal> and the <non_terminal where="15.8.3">for-iterator</non_terminal>. </paragraph>
5   <paragraph>The <non_terminal where="15.8.3">for-condition</non_terminal>, if present, must be a <non_terminal where="15.7.1">boolean-expression</non_terminal> (<hyperlink>14.16</hyperlink>). </paragraph>
6   <paragraph>The <non_terminal where="15.8.3">for-iterator</non_terminal>, if present, consists of a list of <non_terminal where="15.6">statement-expression</non_terminal>s (<hyperlink>15.6</hyperlink>) separated by commas. </paragraph>
7   <paragraph>A for statement is executed as follows: <list><list_item> If a <non_terminal where="15.8.3">for-initializer</non_terminal> is present, the variable initializers or statement expressions are executed in the order they are written. This step is only performed once. </list_item><list_item> If a <non_terminal where="15.8.3">for-condition</non_terminal> is present, it is evaluated. </list_item><list_item> If the <non_terminal where="15.8.3">for-condition</non_terminal> is not present or if the evaluation yields true, control is transferred to the embedded statement. When and if control reaches the end point of the embedded statement (possibly from execution of a continue statement), the expressions of the <non_terminal where="15.8.3">for-iterator</non_terminal>, if any, are evaluated in sequence, and then another iteration is performed, starting with evaluation of the <non_terminal where="15.8.3">for-condition</non_terminal> in the step above. </list_item><list_item> If the <non_terminal where="15.8.3">for-condition</non_terminal> is present and the evaluation yields false, control is transferred to the end point of the for statement. </list_item></list></paragraph>
8   <paragraph>Within the embedded statement of a for statement, a break statement (<hyperlink>15.9.1</hyperlink>) may be used to transfer control to the end point of the for statement (thus ending iteration of the embedded statement), and a continue statement (<hyperlink>15.9.2</hyperlink>) may be used to transfer control to the end point of the embedded statement (thus executing another iteration of the for statement). </paragraph>
9   <paragraph>The embedded statement of a for statement is reachable if one of the following is true: <list><list_item> The for statement is reachable and no <non_terminal where="15.8.3">for-condition</non_terminal> is present. </list_item><list_item> The for statement is reachable and a <non_terminal where="15.8.3">for-condition</non_terminal> is present and does not have the constant value false. </list_item></list></paragraph>
10   <paragraph>The end point of a for statement is reachable if at least one of the following is true: <list><list_item> The for statement contains a reachable break statement that exits the for statement. </list_item><list_item> The for statement is reachable and a <non_terminal where="15.8.3">for-condition</non_terminal> is present and does not have the constant value true. </list_item></list></paragraph>
11 </clause>