braceless one-statement for-loops
This commit is contained in:
@@ -252,15 +252,15 @@
|
||||
c :: b + 3 # c is constrained to `i32`
|
||||
```
|
||||
|
||||
16. for if statements, allow `if (cond) one-line statement` or `if some_func(some_arg) one-line statement` (instead of forcing either `if (cond) { block }` or `if cond { block }`) (implemented)
|
||||
- if statements without a bracketed body must wrap the condition in parentheses UNLESS it's a function call
|
||||
16. allow brace-less single-statement `if` and `for` bodies (implemented)
|
||||
- brace-less bodies must wrap the condition or iterable in parentheses UNLESS it's a function call
|
||||
- brace-less single-statement bodies apply to the then-body, the `else`-body, and the
|
||||
unwrap/guard forms (`if v |x| stmt`); each branch is independent, so braced and
|
||||
unwrap/guard forms (`if (v) |x| stmt`); each branch is independent, so braced and
|
||||
brace-less branches mix freely
|
||||
- the parenthesize-or-call rule constrains only the then-branch condition; `else` and the
|
||||
unwrap `|...|` already delimit, so they need no parentheses
|
||||
- the brace-less statement may sit on the line after the condition
|
||||
- parser-only change (`parse_branch_body` in `compiler/parser/parser.odin`): a brace-less
|
||||
- the parenthesize-or-call rule constrains `if` then-branch conditions (including unwraps)
|
||||
and `for` iterables; `else` bodies have no preceding expression to constrain
|
||||
- the brace-less statement may sit on the following line
|
||||
- parser-only change (`parse_control_body` in `compiler/parser/parser.odin`): a brace-less
|
||||
body is just a 1-element statement slice, so the checker and codegen are unchanged
|
||||
|
||||
17. multi-line strings (implemented; see below)
|
||||
|
||||
Reference in New Issue
Block a user