Remove echo from => macro and fix tclosuremacro test.
This commit is contained in:
parent
232d252885
commit
ed935dfef1
2 changed files with 31 additions and 31 deletions
|
|
@ -54,7 +54,7 @@ macro `=>`*(p, b: expr): expr {.immediate.} =
|
||||||
##
|
##
|
||||||
## passTwoAndTwo((x, y) => x + y) # 4
|
## passTwoAndTwo((x, y) => x + y) # 4
|
||||||
|
|
||||||
echo treeRepr(p)
|
#echo treeRepr(p)
|
||||||
#echo(treeRepr(b))
|
#echo(treeRepr(b))
|
||||||
var params: seq[PNimrodNode] = @[newIdentNode("auto")]
|
var params: seq[PNimrodNode] = @[newIdentNode("auto")]
|
||||||
|
|
||||||
|
|
@ -92,7 +92,7 @@ macro `=>`*(p, b: expr): expr {.immediate.} =
|
||||||
error("Incorrect procedure parameter list.")
|
error("Incorrect procedure parameter list.")
|
||||||
result = newProc(params = params, body = b, procType = nnkLambda)
|
result = newProc(params = params, body = b, procType = nnkLambda)
|
||||||
#echo(result.treeRepr)
|
#echo(result.treeRepr)
|
||||||
echo(result.toStrLit())
|
#echo(result.toStrLit())
|
||||||
#return result # TODO: Bug?
|
#return result # TODO: Bug?
|
||||||
|
|
||||||
macro `->`*(p, b: expr): expr {.immediate.} =
|
macro `->`*(p, b: expr): expr {.immediate.} =
|
||||||
|
|
|
||||||
|
|
@ -10,34 +10,34 @@ noReturn
|
||||||
|
|
||||||
import future
|
import future
|
||||||
|
|
||||||
|
proc twoParams(x: (int, int) -> int): int =
|
||||||
|
result = x(5, 5)
|
||||||
|
|
||||||
|
proc oneParam(x: int -> int): int =
|
||||||
|
x(5)
|
||||||
|
|
||||||
|
proc noParams(x: () -> int): int =
|
||||||
|
result = x()
|
||||||
|
|
||||||
|
proc noReturn(x: () -> void) =
|
||||||
|
x()
|
||||||
|
|
||||||
|
proc doWithOneAndTwo(f: (int, int) -> int): int =
|
||||||
|
f(1,2)
|
||||||
|
|
||||||
|
echo twoParams(proc (a, b): auto = a + b)
|
||||||
|
echo twoParams((x, y) => x + y)
|
||||||
|
|
||||||
|
echo oneParam(x => x+5)
|
||||||
|
|
||||||
|
echo noParams(() => 3)
|
||||||
|
|
||||||
|
echo doWithOneAndTwo((x, y) => x + y)
|
||||||
|
|
||||||
|
noReturn(() -> void => echo("noReturn"))
|
||||||
|
|
||||||
when false:
|
when false:
|
||||||
proc twoParams(x: (int, int) -> int): int =
|
proc pass2(f: (int, int) -> int): (int) -> int =
|
||||||
result = x(5, 5)
|
(x: int) -> int => f(2, x)
|
||||||
|
|
||||||
proc oneParam(x: int -> int): int =
|
#echo pass2((x, y) => x + y)
|
||||||
x(5)
|
|
||||||
|
|
||||||
proc noParams(x: () -> int): int =
|
|
||||||
result = x()
|
|
||||||
|
|
||||||
proc noReturn(x: () -> void) =
|
|
||||||
x()
|
|
||||||
|
|
||||||
proc doWithOneAndTwo(f: (int, int) -> int): int =
|
|
||||||
f(1,2)
|
|
||||||
|
|
||||||
echo twoParams(proc (a, b): auto = a + b)
|
|
||||||
echo twoParams((x, y) => x + y)
|
|
||||||
|
|
||||||
echo oneParam(x => x+5)
|
|
||||||
|
|
||||||
echo noParams(() => 3)
|
|
||||||
|
|
||||||
echo doWithOneAndTwo((x, y) => x + y)
|
|
||||||
|
|
||||||
noReturn(() -> void => echo("noReturn"))
|
|
||||||
|
|
||||||
proc pass2(f: (int, int) -> int): (int) -> int =
|
|
||||||
(x: int) -> int => f(2, x)
|
|
||||||
|
|
||||||
#echo pass2((x, y) => x + y)
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue