Skip to content

Commit

Permalink
0.6.2: support broken nim compilers
Browse files Browse the repository at this point in the history
  • Loading branch information
disruptek committed Oct 3, 2022
1 parent 0b269ca commit 5450760
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
21 changes: 11 additions & 10 deletions cps.nim
Original file line number Diff line number Diff line change
Expand Up @@ -301,13 +301,14 @@ template recover*(c: Continuation): untyped {.used.} =
## Returns the result, i.e. the return value, of a continuation.
discard

{.push experimental: "callOperator".}

macro `()`*[C; R; P](callback: Callback[C, R, P]; arguments: varargs[typed]): R =
## Allows for natural use of call syntax to invoke a callback and
## recover its result in a single statement, inside a continuation.
let call = bindSym"call"
result = newCall(call, callback)
for argument in arguments.items:
result.add argument
result = newCall(bindSym"recover", callback, result)
when not defined cpsNoCallOperator:
{.push experimental: "callOperator".}

macro `()`*[C; R; P](callback: Callback[C, R, P]; arguments: varargs[typed]): R =
## Allows for natural use of call syntax to invoke a callback and
## recover its result in a single statement, inside a continuation.
let call = bindSym"call"
result = newCall(call, callback)
for argument in arguments.items:
result.add argument
result = newCall(bindSym"recover", callback, result)
2 changes: 1 addition & 1 deletion cps.nimble
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "0.6.1"
version = "0.6.2"
author = "disruptek"
description = "continuation-passing style"
license = "MIT"
Expand Down

0 comments on commit 5450760

Please sign in to comment.