summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2017-10-22 09:55:25 +0200
committerAraq <rumpf_a@web.de>2017-10-25 17:37:03 +0200
commit9df766491d35e0c450f5f06c388d9f2ec48a41bf (patch)
tree36bdb065f2b0e59aed8b2032376e47fca83ee386 /lib
parent0be71677d99511c210d7ff62e642dcb32956ed5d (diff)
downloadNim-9df766491d35e0c450f5f06c388d9f2ec48a41bf.tar.gz
default '=sink' and '=destroy' cannot be templates
Diffstat (limited to 'lib')
-rw-r--r--lib/system.nim18
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/system.nim b/lib/system.nim
index ddc72ffaf..10560edaa 100644
--- a/lib/system.nim
+++ b/lib/system.nim
@@ -285,6 +285,13 @@ proc low*(x: string): int {.magic: "Low", noSideEffect.}
   ##  low(2) #=> -9223372036854775808
   ##  low(int) #=> -9223372036854775808
 
+proc shallowCopy*[T](x: var T, y: T) {.noSideEffect, magic: "ShallowCopy".}
+  ## use this instead of `=` for a `shallow copy`:idx:. The shallow copy
+  ## only changes the semantics for sequences and strings (and types which
+  ## contain those). Be careful with the changed semantics though! There
+  ## is a reason why the default assignment does a deep copy of sequences
+  ## and strings.
+
 when defined(nimArrIdx):
   # :array|openarray|string|seq|cstring|tuple
   proc `[]`*[I: Ordinal;T](a: T; i: I): T {.
@@ -293,10 +300,10 @@ when defined(nimArrIdx):
     x: S) {.noSideEffect, magic: "ArrPut".}
   proc `=`*[T](dest: var T; src: T) {.noSideEffect, magic: "Asgn".}
   when defined(nimNewRuntime):
-    template `=destroy`*[T](x: var T) =
+    proc `=destroy`*[T](x: var T) {.inline.} =
       ## generic `destructor`:idx: implementation that can be overriden.
       discard
-    template `=sink`*[T](x: var T; y: T) =
+    proc `=sink`*[T](x: var T; y: T) {.inline.} =
       ## generic `sink`:idx: implementation that can be overriden.
       shallowCopy(x, y)
 
@@ -1488,13 +1495,6 @@ proc add *[T](x: var seq[T], y: openArray[T]) {.noSideEffect.} =
   setLen(x, xl + y.len)
   for i in 0..high(y): x[xl+i] = y[i]
 
-proc shallowCopy*[T](x: var T, y: T) {.noSideEffect, magic: "ShallowCopy".}
-  ## use this instead of `=` for a `shallow copy`:idx:. The shallow copy
-  ## only changes the semantics for sequences and strings (and types which
-  ## contain those). Be careful with the changed semantics though! There
-  ## is a reason why the default assignment does a deep copy of sequences
-  ## and strings.
-
 proc del*[T](x: var seq[T], i: Natural) {.noSideEffect.} =
   ## deletes the item at index `i` by putting ``x[high(x)]`` into position `i`.
   ## This is an O(1) operation.