summary refs log tree commit diff stats
path: root/web
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2016-12-17 14:20:57 +0100
committerAndreas Rumpf <rumpf_a@web.de>2016-12-17 14:20:57 +0100
commitb0134309292e41a9b29777b5bdd79f2a1278a03d (patch)
tree352e573c59ce22e21d8bfe26d38b1e584e25cd15 /web
parent14b9eaee06894f5bf00548117984381d37f16ec7 (diff)
downloadNim-b0134309292e41a9b29777b5bdd79f2a1278a03d.tar.gz
reworked emit pragma; fixes #4730
Diffstat (limited to 'web')
-rw-r--r--web/news/e029_version_0_16_0.rst22
1 files changed, 22 insertions, 0 deletions
diff --git a/web/news/e029_version_0_16_0.rst b/web/news/e029_version_0_16_0.rst
index 2a0c81b46..905504791 100644
--- a/web/news/e029_version_0_16_0.rst
+++ b/web/news/e029_version_0_16_0.rst
@@ -55,6 +55,28 @@ Compiler Additions
 Language Additions
 ------------------
 
+- The ``emit`` pragma now takes a list of Nim expressions instead
+  of a single string literal. This list can easily contain non-strings
+  like template parameters. This means ``emit`` works out of the
+  box with templates and no new quoting rules needed to be introduced.
+  The old way with backtick quoting is still supported but will be
+  deprecated.
+
+.. code-block:: nim
+  type Vector* {.importcpp: "std::vector", header: "<vector>".}[T] = object
+
+  template `[]=`*[T](v: var Vector[T], key: int, val: T) =
+    {.emit: [v, "[", key, "] = ", val, ";"].}
+
+  proc setLen*[T](v: var Vector[T]; size: int) {.importcpp: "resize", nodecl.}
+  proc `[]`*[T](v: var Vector[T], key: int): T {.importcpp: "(#[#])", nodecl.}
+
+  proc main =
+    var v: Vector[float]
+    v.setLen 1
+    v[0] = 6.0
+    echo v[0]
+
 
 Bugfixes
 --------
2272'>91ce8c385 ^
779bc8474 ^

4867931af ^

570deb10d ^

7d17cd34b ^
50e98e6ef ^
e1702ae1e ^
dd57410af ^
a38e3dcb1 ^
b60f15e0d ^
0e45b01b2 ^
f562a5c55 ^
e1702ae1e ^
e1702ae1e ^
8f7aedb3d ^
4faa15f3a ^
285cbcb6a ^
8f7aedb3d ^
f0865fa69 ^
6fee2240c ^
59c65009a ^


4e7c70fd7 ^
4faa15f3a ^





e53c66ef3 ^
ae4645e8d ^
f8e64d879 ^
a8d55fdec ^
8e8231f9d ^
ae4645e8d ^
1b5e03f97 ^

b70fd0400 ^
5163fe7d8 ^
59c65009a ^
d70a9957e ^


76763f51a ^
0613537ca ^












4b1a84170 ^


0c890ff9a ^


59c65009a ^
4b1a84170 ^





























0c890ff9a ^






7d17cd34b ^
e47c3987c ^
8761599aa ^
50e98e6ef ^
691026f50 ^
a236002e5 ^
fb7acd660 ^

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129