Skip to content

Commit

Permalink
stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
krux02 committed May 7, 2019
1 parent 613efcb commit 54290c4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
3 changes: 0 additions & 3 deletions lib/core/macros.nim
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,6 @@ proc `[]`*(n: NimNode, i: int): NimNode {.magic: "NChild", noSideEffect.}
proc `[]`*(n: NimNode, i: BackwardsIndex): NimNode = n[n.len - i.int]
## get `n`'s `i`'th child.

template `^^`(n: NimNode, i: untyped): untyped =
(when i is BackwardsIndex: n.len - int(i) else: int(i))

proc `[]`*[T, U](n: NimNode, x: HSlice[T, U]): seq[NimNode] =
## slice operation for NimNode.
## returns a seq of child of `n` who inclusive range [n[x.a], n[x.b]].
Expand Down
18 changes: 12 additions & 6 deletions lib/pure/sugar.nim
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,18 @@ macro `->`*(p, b: untyped): untyped =

result = createProcType(p, b)

type ListComprehension = object
var lc* {.deprecated.}: ListComprehension

template `|`*(lc: ListComprehension, comp: untyped): untyped {.deprecated.} = lc

macro `[]`*(lc: ListComprehension, comp, typ: untyped): untyped {.deprecated.} =
template `|`*(a,b: untyped): untyped =
## This template should never expand. At some point in the future it
## will be reved without replacement. When it causes problems,
## unexport with ``import future except `|` ``. It is just a hack to
## get useful error messages for the old `[]` brackeds based list
## comprehension syntax.
{.error: "this should never expand. If it does use ``import future except `|` ``.".}

template lc*: untyped =
{.error: "list comprehension syntax got changed. replace lc[ x | ... ] with lc( x | ... ) now!".}

macro lc*(comp, typ: untyped): untyped =
## 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.
Expand Down

0 comments on commit 54290c4

Please sign in to comment.