summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'compiler')
-rw-r--r--compiler/destroyer.nim14
1 files changed, 14 insertions, 0 deletions
diff --git a/compiler/destroyer.nim b/compiler/destroyer.nim
index 9b49a9500..8821e789c 100644
--- a/compiler/destroyer.nim
+++ b/compiler/destroyer.nim
@@ -117,6 +117,20 @@ Rule      Pattern                 Transformed into
 
 Rule 3.2 describes a "cursor" variable, a variable that is only used as a
 view into some data structure. See ``compiler/cursors.nim`` for details.
+
+Note: In order to avoid the very common combination ``reset(x); =sink(x, y)`` for
+variable definitions we must turn "the first sink/assignment" operation into a
+copyMem. This is harder than it looks:
+
+  while true:
+    try:
+      if cond: break # problem if we run destroy(x) here :-/
+      var x = f()
+    finally:
+      destroy(x)
+
+And the C++ optimizers don't sweat to optimize it for us, so we don't have
+to do it.
 ]##
 
 import
le='author Araq <rumpf_a@web.de> 2010-11-18 22:26:20 +0100 committer Araq <rumpf_a@web.de> 2010-11-18 22:26:20 +0100 docgen understands and ignores *when false*' href='/ahoang/Nim/commit/tinyc/config.h?h=devel&id=adf13aaea379d482ad4289d349a9d475bc2c06a6'>adf13aaea ^
47886978c ^





1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22