diff options
author | Timothee Cour <timothee.cour2@gmail.com> | 2021-04-20 00:25:28 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-20 00:25:28 -0700 |
commit | 4742e6e1fdc6cebd3052875748fa10ad44c8a42e (patch) | |
tree | 68c48ca5c0abaf8f93761b58356a2d8b43c78127 | |
parent | 68e7ed9c57605bc98d3ab7625374113386e62ee7 (diff) | |
download | Nim-4742e6e1fdc6cebd3052875748fa10ad44c8a42e.tar.gz |
followup #16714: add -d:nimLegacyUnarySlice + changelog (#17794)
-rw-r--r-- | changelog.md | 3 | ||||
-rw-r--r-- | lib/system.nim | 10 |
2 files changed, 13 insertions, 0 deletions
diff --git a/changelog.md b/changelog.md index 3caf5e92d..0537b3d6a 100644 --- a/changelog.md +++ b/changelog.md @@ -54,6 +54,9 @@ - `hashes.hash(proc|ptr|ref|pointer)` now calls `hash(int)` and honors `-d:nimIntHash1`, `hashes.hash(closure)` has also been improved. +- The unary slice `..b` was removed, use `0..b` instead or use `-d:nimLegacyUnarySlice` + for a deprecation period. + ## Standard library additions and changes - Added support for parenthesized expressions in `strformat` diff --git a/lib/system.nim b/lib/system.nim index d73ef6dbe..41749c27a 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -510,6 +510,16 @@ proc `..`*[T, U](a: sink T, b: sink U): HSlice[T, U] {.noSideEffect, inline, mag ## echo a[2 .. 3] # @[30, 40] result = HSlice[T, U](a: a, b: b) +when defined(nimLegacyUnarySlice): + proc `..`*[T](b: sink T): HSlice[int, T] + {.noSideEffect, inline, magic: "DotDot", deprecated: "replace `..b` with `0..b`".} = + ## Unary `slice`:idx: operator that constructs an interval `[default(int), b]`. + ## + ## .. code-block:: Nim + ## let a = [10, 20, 30, 40, 50] + ## echo a[.. 2] # @[10, 20, 30] + result = HSlice[int, T](a: 0, b: b) + when defined(hotCodeReloading): {.pragma: hcrInline, inline.} else: |