Re: Type inference and pragma issues in lambdas
Oh, right, the issue is for proc within tuples: [https://github.com/nim-lang/Nim/issues/7808](https://github.com/nim-lang/Nim/issues/7808)
Re: Type inference and pragma issues in lambdas
@adobai, this is work proc doIt(x: string, p: proc()) = echo x doIt("xx", proc() = echo "aa") Run
Re: Type inference and pragma issues in lambdas
@juancarlospaco what's that supposed to be? @mratsim the sugar module produces the same. Also, I REALLY don't want to type down {.closure.} every time I create a lambda function because it'd be insane. Also, I think it's wrong for a lambda to assume that it'll be a {.closure.} - it should allow everything by default unless explicitly defined otherwise.
Re: Type inference and pragma issues in lambdas
For some reason procvar (proc parameter) sometimes need some help with either {.closure.} or {.nimcall.} proc doIt(x: (string, proc(){.closure.})) = echo x[0] doIt(("xx", proc() {.closure.} = echo "aa")) Run Be sure to check the `sugar` module as well for `->` and `=>` shortcuts proc passTwoAndTwo(f: (int, int) -> int): int = f(2, 2) passTwoAndTwo((x, y) => x + y) # 4 Run
Re: Type inference and pragma issues in lambdas
`(func: auto = "Lambda")() ` Run
Type inference and pragma issues in lambdas
Hi, > Why is this an issue: proc doIt(x: (string, proc(): void)) = echo x[0] doIt(("xx", proc(): void = echo "aa")) Run Hint: used config file '/home/steven/.choosenim/toolchains/nim-0.19.0/config/nim.cfg' [Conf] Hint: system [Processing] Hint: t [Processing] t.nim(5, 5) Error: type mismatch: got but expected one of: proc doIt(x: (string, proc (): void)) expression: doIt(("xx", proc (): void = echo ["aa"])) Run Is there a sane way in nim to do lambdas?
Re: Type inference and pragma issues in lambdas
But this is ok: proc doIt(x: (string, proc(): void)) = echo x[0] proc make1(x: string, y: proc(): void): (string, proc(): void) = (x, y) doIt(make1("xx", proc(): void = echo "aa")) Run Doesn't make any sense.