lenVarargs: number of varargs elements (#12907)

This commit is contained in:
Timothee Cour
2019-12-23 09:42:32 +01:00
committed by Andreas Rumpf
parent 2e7c9eb6a8
commit a0980c88c9
2 changed files with 64 additions and 0 deletions

View File

@@ -4198,6 +4198,11 @@ type
NimNode* {.magic: "PNimrodNode".} = ref NimNodeObj
## Represents a Nim AST node. Macros operate on this type.
macro lenVarargs*(x: varargs[untyped]): int {.since: (1, 1).} =
## returns number of variadic arguments in `x`
proc lenVarargsImpl(x: NimNode): NimNode {.magic: "LengthOpenArray", noSideEffect.}
lenVarargsImpl(x)
when false:
template eval*(blk: typed): typed =
## Executes a block of code at compile time just as if it was a macro.