implemented a[^1] notation

This commit is contained in:
Araq
2015-03-26 02:12:26 +01:00
parent 36b6bfaf78
commit 5d63ecb3a4
13 changed files with 209 additions and 50 deletions

View File

@@ -222,8 +222,8 @@ type
set*{.magic: "Set".}[T] ## Generic type to construct bit sets.
type
Slice* {.final, pure.}[T] = object ## builtin slice type
a*, b*: T ## the bounds
Slice*[T] = object ## builtin slice type
a*, b*: T ## the bounds
when defined(nimalias):
{.deprecated: [TSlice: Slice].}
@@ -3247,4 +3247,12 @@ proc procCall*(x: expr) {.magic: "ProcCall".} =
## procCall someMethod(a, b)
discard
proc `^`*(x: int): int {.noSideEffect, magic: "Roof".} =
## builtin `roof`:idx: operator that can be used for convenient array access.
## ``a[^x]`` is rewritten to ``a[a.len-x]``. However currently the ``a``
## expression must not have side effects for this to compile. Note that since
## this is a builtin, it automatically works for all kinds of
## overloaded ``[]`` or ``[]=`` accessors.
discard
{.pop.} #{.push warning[GcMem]: off.}