aboutsummaryrefslogtreecommitdiff
path: root/docs/SPEC.md
diff options
context:
space:
mode:
authorGravatar zinc <zinc@downsta.ir> 2026-10-14 19:56:53 +0330
committerGravatar zinc <zinc@downsta.ir> 2026-10-14 21:24:34 +0330
commita3450d687628661aa0316cfc995934f6ce0c4e90 (patch)
tree75ed354e2c274317df25e3dcdd9ab5ea72dff2f2 /docs/SPEC.md
parenttodo: run.py's sieve checksum fails on main (diff)
defer: any single statement (if/else, loops, switch, unchecked, unbounded), not just an expression or a block
Diffstat (limited to 'docs/SPEC.md')
-rw-r--r--docs/SPEC.md2
1 files changed, 1 insertions, 1 deletions
diff --git a/docs/SPEC.md b/docs/SPEC.md
index 32afdfb..aad7ff6 100644
--- a/docs/SPEC.md
+++ b/docs/SPEC.md
@@ -640,7 +640,7 @@ int y = 7; asm { y @ 1 + y ! } // y is 8
### 4.14 defer
-4.14.1 `defer expr;` and `defer { statements }` register a statement that runs when the block that contains the `defer` ends. the tokens are kept, not compiled, at the `defer`; the compiler compiles them again, in place, at every point where control leaves the block: the end of the block, and a `return`, `break` or `continue` that leaves it. (a function body is a block; so are a loop or `if` body, a `switch` case and a block expression.) the code is therefore duplicated at each exit.
+4.14.1 `defer` followed by one statement (`defer expr;`, `defer { statements }`, `defer if (c) a; else b;`, a loop, a `switch`, or an `unchecked` or `unbounded` statement) registers that statement; it runs when the block that contains the `defer` ends. the tokens are kept, not compiled, at the `defer`; the compiler compiles them again, in place, at every point where control leaves the block: the end of the block, and a `return`, `break` or `continue` that leaves it. (a function body is a block; so are a loop or `if` body, a `switch` case and a block expression.) the code is therefore duplicated at each exit.
4.14.2 several defers in one block run in reverse order of registration. an early exit runs the defers of every block it leaves, innermost block first, and within a block newest first. `return` runs those of the whole function, `break` and `continue` only those inside the loop or switch they leave.