Tiny since cleanup (#13286)
This commit is contained in:
parent
be795bbf1a
commit
fb94836bc7
4 changed files with 111 additions and 111 deletions
|
|
@ -2357,7 +2357,7 @@ proc formatBiggestFloat*(f: BiggestFloat, format: FloatFormatMode = ffDefault,
|
||||||
# but nothing else is possible:
|
# but nothing else is possible:
|
||||||
if buf[i] in {'.', ','}: result[i] = decimalSep
|
if buf[i] in {'.', ','}: result[i] = decimalSep
|
||||||
else: result[i] = buf[i]
|
else: result[i] = buf[i]
|
||||||
when (NimMajor, NimMinor) >= (1, 1):
|
since (1, 1):
|
||||||
# remove trailing dot, compatible with Python's formatter and JS backend
|
# remove trailing dot, compatible with Python's formatter and JS backend
|
||||||
if result[^1] == decimalSep:
|
if result[^1] == decimalSep:
|
||||||
result.setLen(len(result)-1)
|
result.setLen(len(result)-1)
|
||||||
|
|
|
||||||
|
|
@ -189,8 +189,7 @@ macro capture*(locals: openArray[typed], body: untyped): untyped {.since: (1, 1)
|
||||||
result.add(newProc(newEmptyNode(), params, body, nnkProcDef))
|
result.add(newProc(newEmptyNode(), params, body, nnkProcDef))
|
||||||
for arg in locals: result.add(arg)
|
for arg in locals: result.add(arg)
|
||||||
|
|
||||||
when (NimMajor, NimMinor) >= (1, 1):
|
macro outplace*[T](arg: T, call: untyped; inplaceArgPosition: static[int] = 1): T {.since: (1, 1).} =
|
||||||
macro outplace*[T](arg: T, call: untyped; inplaceArgPosition: static[int] = 1): T =
|
|
||||||
## Turns an `in-place`:idx: algorithm into one that works on
|
## Turns an `in-place`:idx: algorithm into one that works on
|
||||||
## a copy and returns this copy. The second parameter is the
|
## a copy and returns this copy. The second parameter is the
|
||||||
## index of the calling expression that is replaced by a copy
|
## index of the calling expression that is replaced by a copy
|
||||||
|
|
@ -216,7 +215,7 @@ when (NimMajor, NimMinor) >= (1, 1):
|
||||||
copyNimNode(call).add callsons,
|
copyNimNode(call).add callsons,
|
||||||
tmp)
|
tmp)
|
||||||
|
|
||||||
proc transLastStmt(n, res, bracketExpr: NimNode): (NimNode, NimNode, NimNode) =
|
proc transLastStmt(n, res, bracketExpr: NimNode): (NimNode, NimNode, NimNode) {.since: (1, 1).} =
|
||||||
# Looks for the last statement of the last statement, etc...
|
# Looks for the last statement of the last statement, etc...
|
||||||
case n.kind
|
case n.kind
|
||||||
of nnkIfExpr, nnkIfStmt, nnkTryStmt, nnkCaseStmt:
|
of nnkIfExpr, nnkIfStmt, nnkTryStmt, nnkCaseStmt:
|
||||||
|
|
@ -253,7 +252,7 @@ when (NimMajor, NimMinor) >= (1, 1):
|
||||||
template adder(res, v) = res.add(v)
|
template adder(res, v) = res.add(v)
|
||||||
result[0] = getAst(adder(res, n))
|
result[0] = getAst(adder(res, n))
|
||||||
|
|
||||||
macro collect*(init, body: untyped): untyped =
|
macro collect*(init, body: untyped): untyped {.since: (1, 1).} =
|
||||||
## Comprehension for seq/set/table collections. ``init`` is
|
## Comprehension for seq/set/table collections. ``init`` is
|
||||||
## the init call, and so custom collections are supported.
|
## the init call, and so custom collections are supported.
|
||||||
##
|
##
|
||||||
|
|
@ -307,6 +306,7 @@ when (NimMajor, NimMinor) >= (1, 1):
|
||||||
result = newTree(nnkStmtListExpr, newVarStmt(res, call), resBody, res)
|
result = newTree(nnkStmtListExpr, newVarStmt(res, call), resBody, res)
|
||||||
|
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
|
since (1, 1):
|
||||||
import algorithm
|
import algorithm
|
||||||
|
|
||||||
var a = @[1, 2, 3, 4, 5, 6, 7, 8, 9]
|
var a = @[1, 2, 3, 4, 5, 6, 7, 8, 9]
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ macro lenTuple*(t: typedesc[tuple]): int {.since: (1, 1).} =
|
||||||
## Return number of elements of `T`
|
## Return number of elements of `T`
|
||||||
newLit t.len
|
newLit t.len
|
||||||
|
|
||||||
when (NimMajor, NimMinor) >= (1, 1):
|
since (1, 1):
|
||||||
template get*(T: typedesc[tuple], i: static int): untyped =
|
template get*(T: typedesc[tuple], i: static int): untyped =
|
||||||
## Return `i`th element of `T`
|
## Return `i`th element of `T`
|
||||||
# Note: `[]` currently gives: `Error: no generic parameters allowed for ...`
|
# Note: `[]` currently gives: `Error: no generic parameters allowed for ...`
|
||||||
|
|
|
||||||
|
|
@ -52,5 +52,5 @@ else:
|
||||||
template since(version, body: untyped) {.dirty.} =
|
template since(version, body: untyped) {.dirty.} =
|
||||||
## limitation: can't be used to annotate a template (eg typetraits.get), would
|
## limitation: can't be used to annotate a template (eg typetraits.get), would
|
||||||
## error: cannot attach a custom pragma.
|
## error: cannot attach a custom pragma.
|
||||||
when version <= (NimMajor, NimMinor):
|
when (NimMajor, NimMinor) >= version:
|
||||||
body
|
body
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue