summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorTimothee Cour <timothee.cour2@gmail.com>2019-12-23 09:42:32 +0100
committerAndreas Rumpf <rumpf_a@web.de>2019-12-23 09:42:32 +0100
commita0980c88c934dcbefb17099ca68f0d775aef44cd (patch)
tree61ba3b50ca28554650e93209e9f320a7c969f76d /lib
parent2e7c9eb6a8dea7e4ca6b268020058b46f6b16580 (diff)
downloadNim-a0980c88c934dcbefb17099ca68f0d775aef44cd.tar.gz
lenVarargs: number of varargs elements (#12907)
Diffstat (limited to 'lib')
-rw-r--r--lib/system.nim5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/system.nim b/lib/system.nim
index 05029b9d7..a1f94218e 100644
--- a/lib/system.nim
+++ b/lib/system.nim
@@ -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.