deprecated unary '<'
This commit is contained in:
parent
c17f6c7837
commit
70ea45cdba
56 changed files with 259 additions and 258 deletions
|
|
@ -20,3 +20,5 @@
|
|||
recursive types can be created across module boundaries. See
|
||||
[package level objects](https://nim-lang.org/docs/manual.html#package-level-objects)
|
||||
for more information.
|
||||
- The **unary** ``<`` is now deprecated, for ``.. <`` use ``..<`` for other usages
|
||||
use the ``pred`` proc.
|
||||
|
|
|
|||
|
|
@ -809,7 +809,7 @@ proc getTypeDescAux(m: BModule, origTyp: PType, check: var IntSet): Rope =
|
|||
var chunkStart = 0
|
||||
while i < cppName.data.len:
|
||||
if cppName.data[i] == '\'':
|
||||
var chunkEnd = <i
|
||||
var chunkEnd = i-1
|
||||
var idx, stars: int
|
||||
if scanCppGenericSlot(cppName.data, i, idx, stars):
|
||||
result.add cppName.data.substr(chunkStart, chunkEnd)
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ proc evalTemplateArgs(n: PNode, s: PSym; fromHlo: bool): PNode =
|
|||
# now that we have working untyped parameters.
|
||||
genericParams = if sfImmediate in s.flags or fromHlo: 0
|
||||
else: s.ast[genericParamsPos].len
|
||||
expectedRegularParams = <s.typ.len
|
||||
expectedRegularParams = s.typ.len-1
|
||||
givenRegularParams = totalParams - genericParams
|
||||
if givenRegularParams < 0: givenRegularParams = 0
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ proc applyPatterns(c: PContext, n: PNode): PNode =
|
|||
# we apply the last pattern first, so that pattern overriding is possible;
|
||||
# however the resulting AST would better not trigger the old rule then
|
||||
# anymore ;-)
|
||||
for i in countdown(<c.patterns.len, 0):
|
||||
for i in countdown(c.patterns.len-1, 0):
|
||||
let pattern = c.patterns[i]
|
||||
if not isNil(pattern):
|
||||
let x = applyRule(c, pattern, result)
|
||||
|
|
|
|||
|
|
@ -1145,7 +1145,7 @@ proc semProcAnnotation(c: PContext, prc: PNode;
|
|||
validPragmas: TSpecialWords): PNode =
|
||||
var n = prc.sons[pragmasPos]
|
||||
if n == nil or n.kind == nkEmpty: return
|
||||
for i in countup(0, <n.len):
|
||||
for i in countup(0, n.len-1):
|
||||
var it = n.sons[i]
|
||||
var key = if it.kind == nkExprColonExpr: it.sons[0] else: it
|
||||
let m = lookupMacro(c, key)
|
||||
|
|
|
|||
|
|
@ -275,7 +275,7 @@ proc transformWhile(c: PTransf; n: PNode): PTransNode =
|
|||
var body = newTransNode(n)
|
||||
for i in 0..n.len-2:
|
||||
body[i] = transform(c, n.sons[i])
|
||||
body[<n.len] = transformLoopBody(c, n.sons[<n.len])
|
||||
body[n.len-1] = transformLoopBody(c, n.sons[n.len-1])
|
||||
result[1] = body
|
||||
discard c.breakSyms.pop
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ proc renderPlainSymbolName*(n: PNode): string =
|
|||
result = ""
|
||||
case n.kind
|
||||
of nkPostfix, nkAccQuoted:
|
||||
result = renderPlainSymbolName(n[<n.len])
|
||||
result = renderPlainSymbolName(n[n.len-1])
|
||||
of nkIdent:
|
||||
result = n.ident.s
|
||||
of nkSym:
|
||||
|
|
@ -59,7 +59,7 @@ proc renderType(n: PNode): string =
|
|||
assert len(params) > 0
|
||||
result = "proc("
|
||||
for i in 1 ..< len(params): result.add(renderType(params[i]) & ',')
|
||||
result[<len(result)] = ')'
|
||||
result[len(result)-1] = ')'
|
||||
else:
|
||||
result = "proc"
|
||||
of nkIdentDefs:
|
||||
|
|
@ -73,12 +73,12 @@ proc renderType(n: PNode): string =
|
|||
of nkTupleTy:
|
||||
result = "tuple["
|
||||
for i in 0 ..< len(n): result.add(renderType(n[i]) & ',')
|
||||
result[<len(result)] = ']'
|
||||
result[len(result)-1] = ']'
|
||||
of nkBracketExpr:
|
||||
assert len(n) >= 2
|
||||
result = renderType(n[0]) & '['
|
||||
for i in 1 ..< len(n): result.add(renderType(n[i]) & ',')
|
||||
result[<len(result)] = ']'
|
||||
result[len(result)-1] = ']'
|
||||
else: result = ""
|
||||
assert(not result.isNil)
|
||||
|
||||
|
|
|
|||
|
|
@ -1688,8 +1688,7 @@ proc evalMacroCall*(module: PSym; cache: IdentCache, n, nOrig: PNode,
|
|||
# arity here too:
|
||||
if sym.typ.len > n.safeLen and sym.typ.len > 1:
|
||||
globalError(n.info, "in call '$#' got $#, but expected $# argument(s)" % [
|
||||
n.renderTree,
|
||||
$ <n.safeLen, $ <sym.typ.len])
|
||||
n.renderTree, $(n.safeLen-1), $(sym.typ.len-1)])
|
||||
|
||||
setupGlobalCtx(module, cache)
|
||||
var c = globalCtx
|
||||
|
|
|
|||
|
|
@ -652,13 +652,17 @@ proc sizeof*[T](x: T): int {.magic: "SizeOf", noSideEffect.}
|
|||
when defined(nimtypedescfixed):
|
||||
proc sizeof*(x: typedesc): int {.magic: "SizeOf", noSideEffect.}
|
||||
|
||||
proc `<`*[T](x: Ordinal[T]): T {.magic: "UnaryLt", noSideEffect.}
|
||||
proc `<`*[T](x: Ordinal[T]): T {.magic: "UnaryLt", noSideEffect, deprecated.}
|
||||
## unary ``<`` that can be used for nice looking excluding ranges:
|
||||
##
|
||||
## .. code-block:: nim
|
||||
## for i in 0 .. <10: echo i #=> 0 1 2 3 4 5 6 7 8 9
|
||||
##
|
||||
## Semantically this is the same as ``pred``.
|
||||
##
|
||||
## **Deprecated since version 0.18.0**. For the common excluding range
|
||||
## write ``0 ..< 10`` instead of ``0 .. < 10`` (look at the spacing).
|
||||
## For ``<x`` write ``pred(x)``.
|
||||
|
||||
proc succ*[T](x: Ordinal[T], y = 1): T {.magic: "Succ", noSideEffect.}
|
||||
## returns the ``y``-th successor of the value ``x``. ``T`` has to be
|
||||
|
|
@ -3410,6 +3414,30 @@ proc `/`*(x, y: int): float {.inline, noSideEffect.} =
|
|||
## integer division that results in a float.
|
||||
result = toFloat(x) / toFloat(y)
|
||||
|
||||
proc `^`*[T](x: int; y: openArray[T]): int {.noSideEffect, magic: "Roof".}
|
||||
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
|
||||
|
||||
template `..^`*(a, b: untyped): untyped =
|
||||
## a shortcut for '.. ^' to avoid the common gotcha that a space between
|
||||
## '..' and '^' is required.
|
||||
a .. ^b
|
||||
|
||||
template `..<`*(a, b: untyped): untyped {.dirty.} =
|
||||
## a shortcut for 'a..pred(b)'.
|
||||
a .. pred(b)
|
||||
|
||||
iterator `..<`*[S,T](a: S, b: T): T =
|
||||
var i = T(a)
|
||||
while i < b:
|
||||
yield i
|
||||
inc i
|
||||
|
||||
template spliceImpl(s, a, L, b: untyped): untyped =
|
||||
# make room for additional elements or cut:
|
||||
var shift = b.len - max(0,L) # ignore negative slice size
|
||||
|
|
@ -3853,31 +3881,6 @@ proc procCall*(x: untyped) {.magic: "ProcCall", compileTime.} =
|
|||
## procCall someMethod(a, b)
|
||||
discard
|
||||
|
||||
proc `^`*[T](x: int; y: openArray[T]): int {.noSideEffect, magic: "Roof".}
|
||||
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
|
||||
|
||||
template `..^`*(a, b: untyped): untyped =
|
||||
## a shortcut for '.. ^' to avoid the common gotcha that a space between
|
||||
## '..' and '^' is required.
|
||||
a .. ^b
|
||||
|
||||
template `..<`*(a, b: untyped): untyped {.dirty.} =
|
||||
## a shortcut for '.. <' to avoid the common gotcha that a space between
|
||||
## '..' and '<' is required.
|
||||
a .. <b
|
||||
|
||||
iterator `..<`*[S,T](a: S, b: T): T =
|
||||
var i = T(a)
|
||||
while i < b:
|
||||
yield i
|
||||
inc i
|
||||
|
||||
proc xlen*(x: string): int {.magic: "XLenStr", noSideEffect.} = discard
|
||||
proc xlen*[T](x: seq[T]): int {.magic: "XLenSeq", noSideEffect.} =
|
||||
## returns the length of a sequence or a string without testing for 'nil'.
|
||||
|
|
|
|||
3
todo.txt
3
todo.txt
|
|
@ -3,7 +3,6 @@ version 1.0 battle plan
|
|||
|
||||
- make nimresolve part of the Nim compiler and add support for
|
||||
'import staticExec()'
|
||||
- deprecate unary '<'
|
||||
- remove 'mod x' type rule
|
||||
- implement x[^1] differently, no compiler magic
|
||||
- fix "high priority" bugs
|
||||
|
|
@ -24,8 +23,6 @@ Not critical for 1.0
|
|||
'static[T]' mess in the compiler!
|
||||
- ``not`` or ``~`` for the effects system
|
||||
- figure out why C++ bootstrapping is so much slower
|
||||
- The bitwise 'not' operator cold be renamed to 'bnot' to
|
||||
prevent 'not 4 == 5' from compiling. -> requires 'mixin' annotation for procs!
|
||||
- make 'nil' work for 'add':
|
||||
- resizeString
|
||||
- incrSeq
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue