This module implements experimental features which may soon be moved to the system module (or other more appropriate modules).
Macros
macro `=>`(p, b: expr): expr {.immediate.}
-
Syntax sugar for anonymous procedures.
proc passTwoAndTwo(f: (int, int) -> int): int = f(2, 2) passTwoAndTwo((x, y) => x + y) # 4
Source macro `->`(p, b: expr): expr {.immediate.}
-
Syntax sugar for procedure types.
proc pass2(f: (float, float) -> float): float = f(2, 2) # is the same as: proc pass2(f: proc (x, y: float): float): float = f(2, 2)
Source macro `[]`(lc: ListComprehension; comp, typ: expr): expr
-
List comprehension, returns a sequence. comp is the actual list comprehension, for example x | (x <- 1..10, x mod 2 == 0). typ is the type that will be stored inside the result seq.
echo lc[x | (x <- 1..10, x mod 2 == 0), int] const n = 20 echo lc[(x,y,z) | (x <- 1..n, y <- x..n, z <- y..n, x*x + y*y == z*z), tuple[a,b,c: int]]
Source