From 30737ea34b95b10cd9add766a4397b7e3934efb4 Mon Sep 17 00:00:00 2001 From: apense Date: Mon, 6 Jul 2015 15:47:23 -0400 Subject: [PATCH 1/3] Added safeAdd documentation --- lib/system.nim | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/system.nim b/lib/system.nim index 2677e4990..4ea880b4b 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -3286,14 +3286,19 @@ when declared(initDebugger): when hasAlloc: # XXX: make these the default (or implement the NilObject optimization) proc safeAdd*[T](x: var seq[T], y: T) {.noSideEffect.} = + ## Add `y` to `x` unless `x` is not yet initialized; in that case, `x` + ## becomes `@[y]` if x == nil: x = @[y] else: x.add(y) proc safeAdd*(x: var string, y: char) = + ## Add `y` to `x`. If `x` is `nil` it is initialized to `""` if x == nil: x = "" x.add(y) proc safeAdd*(x: var string, y: string) = + ## Add `y` to `x` unless `x` is not yet initalized; in that case, `x` + ## becomes `y` if x == nil: x = y else: x.add(y) From 5a2e575bb636b429ce0fb7c5e01e5eb067d16804 Mon Sep 17 00:00:00 2001 From: apense Date: Thu, 9 Jul 2015 00:03:18 -0400 Subject: [PATCH 2/3] Doubled ticks --- lib/system.nim | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/system.nim b/lib/system.nim index 4ea880b4b..bf3e49ce1 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -3286,19 +3286,19 @@ when declared(initDebugger): when hasAlloc: # XXX: make these the default (or implement the NilObject optimization) proc safeAdd*[T](x: var seq[T], y: T) {.noSideEffect.} = - ## Add `y` to `x` unless `x` is not yet initialized; in that case, `x` - ## becomes `@[y]` + ## Add ``y`` to ``x`` unless ``x`` is not yet initialized; in that case, + ## ``x`` becomes ``@[y]`` if x == nil: x = @[y] else: x.add(y) proc safeAdd*(x: var string, y: char) = - ## Add `y` to `x`. If `x` is `nil` it is initialized to `""` + ## Add ``y`` to ``x``. If ``x`` is ``nil`` it is initialized to ``""`` if x == nil: x = "" x.add(y) proc safeAdd*(x: var string, y: string) = - ## Add `y` to `x` unless `x` is not yet initalized; in that case, `x` - ## becomes `y` + ## Add ``y`` to ``x`` unless ``x`` is not yet initalized; in that case, ``x`` + ## becomes ``y`` if x == nil: x = y else: x.add(y) From a6e660e9358b5a852c3020cbf75232bf05e6972c Mon Sep 17 00:00:00 2001 From: apense Date: Thu, 9 Jul 2015 14:02:21 -0400 Subject: [PATCH 3/3] Corrected documentation --- lib/system.nim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/system.nim b/lib/system.nim index bf3e49ce1..5b257dc6d 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -3286,18 +3286,18 @@ when declared(initDebugger): when hasAlloc: # XXX: make these the default (or implement the NilObject optimization) proc safeAdd*[T](x: var seq[T], y: T) {.noSideEffect.} = - ## Add ``y`` to ``x`` unless ``x`` is not yet initialized; in that case, + ## Adds ``y`` to ``x`` unless ``x`` is not yet initialized; in that case, ## ``x`` becomes ``@[y]`` if x == nil: x = @[y] else: x.add(y) proc safeAdd*(x: var string, y: char) = - ## Add ``y`` to ``x``. If ``x`` is ``nil`` it is initialized to ``""`` + ## Adds ``y`` to ``x``. If ``x`` is ``nil`` it is initialized to ``""`` if x == nil: x = "" x.add(y) proc safeAdd*(x: var string, y: string) = - ## Add ``y`` to ``x`` unless ``x`` is not yet initalized; in that case, ``x`` + ## Adds ``y`` to ``x`` unless ``x`` is not yet initalized; in that case, ``x`` ## becomes ``y`` if x == nil: x = y else: x.add(y)