deprecated list comprehension (#10636)
This commit is contained in:
parent
33ddc21057
commit
c59fa80367
1 changed files with 4 additions and 3 deletions
|
|
@ -123,11 +123,11 @@ macro `->`*(p, b: untyped): untyped =
|
||||||
result = createProcType(p, b)
|
result = createProcType(p, b)
|
||||||
|
|
||||||
type ListComprehension = object
|
type ListComprehension = object
|
||||||
var lc*: ListComprehension
|
var lc* {.deprecated.}: ListComprehension
|
||||||
|
|
||||||
template `|`*(lc: ListComprehension, comp: untyped): untyped = lc
|
template `|`*(lc: ListComprehension, comp: untyped): untyped {.deprecated.} = lc
|
||||||
|
|
||||||
macro `[]`*(lc: ListComprehension, comp, typ: untyped): untyped =
|
macro `[]`*(lc: ListComprehension, comp, typ: untyped): untyped {.deprecated.} =
|
||||||
## List comprehension, returns a sequence. `comp` is the actual list
|
## List comprehension, returns a sequence. `comp` is the actual list
|
||||||
## comprehension, for example ``x | (x <- 1..10, x mod 2 == 0)``. `typ` is
|
## comprehension, for example ``x | (x <- 1..10, x mod 2 == 0)``. `typ` is
|
||||||
## the type that will be stored inside the result seq.
|
## the type that will be stored inside the result seq.
|
||||||
|
|
@ -139,6 +139,7 @@ macro `[]`*(lc: ListComprehension, comp, typ: untyped): untyped =
|
||||||
## const n = 20
|
## const n = 20
|
||||||
## echo lc[(x,y,z) | (x <- 1..n, y <- x..n, z <- y..n, x*x + y*y == z*z),
|
## 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]]
|
## tuple[a,b,c: int]]
|
||||||
|
## **Deprecated since version 0.19.9**
|
||||||
|
|
||||||
expectLen(comp, 3)
|
expectLen(comp, 3)
|
||||||
expectKind(comp, nnkInfix)
|
expectKind(comp, nnkInfix)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue