Skip to content

Commit 675246b

Browse files
committed
Some rephrasing of rang-based for docs
1 parent 2a89206 commit 675246b

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

doc/sql.extensions/README.range_based_for.md

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,40 @@
22

33
## Description
44

5-
The range-based `FOR` statement is used to iterate over a range of numeric values. The iteration is performed in
6-
increasing order when used with `TO` clause and in decreasing order when used with `DOWNTO` clause.
5+
The range-based `FOR` statement iterates over a range of numeric values. The iteration is performed in
6+
increasing order with the `TO` clause, or in decreasing order with the `DOWNTO` clause.
77

88
## Syntax
99

1010
```
1111
[<label> :]
12-
FOR <variable> = <initial value> {TO | DOWNTO} <final value> [BY <by value>] DO
13-
<statement>
12+
FOR <variable> = <initial value> {TO | DOWNTO} <final value> [BY <step value>] DO
13+
<compound statement>
1414
```
1515

1616
## Notes
1717

18-
- If omitted, `<by value>` is `1`.
18+
- If omitted, `<step value>` is `1`.
1919
- `<variable>` also accepts parameters.
20-
- `<variable>`, `<initial value>`, `<final value>` and `<by value>` must be expressions of exact numeric types.
21-
- `BREAK` or `LEAVE [<label>]` can be used to exit the loop.
22-
- `CONTINUE [<label>]` can be used to restart the next loop iteration.
23-
- `<variable>` can be assigned by user code inside the loop.
20+
- `<variable>`, `<initial value>`, `<final value>` and `<step value>` must be expressions of exact numeric types.
21+
- `BREAK` or `LEAVE [<label>]` exits the loop.
22+
- `CONTINUE [<label>]` skips the remainder of the loop body and starts the next iteration.
23+
- `<variable>` can be modified by the loop body.
2424

2525
## Execution
2626

27-
- `<initial value>` is evaluated and assigned to `<variable>`. If it is `NULL`, the loop is not executed.
28-
- `<final value>` is evaluated and assigned to a temporary variable. If it is `NULL`, the loop is not executed.
29-
- `<by value>` (or its default `1` value) is evaluated and assigned to a temporary variable.
30-
If it is `NULL`, the loop is not executed. If it is zero or negative, an error is raised.
27+
- `<initial value>` is evaluated and assigned to `<variable>`. If `NULL`, the loop exits immediately.
28+
- `<final value>` is evaluated and assigned to a temporary variable. If `NULL`, the loop exits immediately.
29+
- `<step value>` (or its default value `1`) is evaluated and assigned to a temporary variable.
30+
If `NULL`, the loop exits immediately. If zero or negative, an error is raised.
3131
- Loop starts:
32-
- If it is not the first iteration:
33-
- If `<variable>` is `NULL`, the loop is exited.
34-
- `<variable>` is incremented (`TO`) or decremented (`DOWNTO`) by the cached `<by value>`.
32+
- If not the first iteration:
33+
- If `<variable>` is `NULL`, the loop exits.
34+
- `<variable>` is incremented (`TO`) or decremented (`DOWNTO`) by the cached `<step value>`.
3535
- `<variable>` is compared (less than or equal for `TO` or greater than or equal for `DOWNTO`) to the cached
36-
`<final value>` and if it is out of range, the loop is exited.
37-
- Loop continues to the next iteration.
36+
`<final value>` and if false, the loop exits.
37+
- The body (`<compund statement>`) of the loop is executed.
38+
- The loop continues to the next iteration.
3839

3940
## Examples
4041

0 commit comments

Comments
 (0)