implemented 'koch pdf'

This commit is contained in:
Araq
2014-12-19 13:44:56 +01:00
parent d4230e052d
commit 76c3b314dc
10 changed files with 30 additions and 23 deletions

View File

@@ -1,12 +1,12 @@
discard """
line: 12
errormsg: "type mismatch: got (proc (int){.closure, gcsafe.})"
errormsg: "type mismatch: got (proc (int){.closure, gcsafe, locks: 0.})"
"""
proc ugh[T](x: T) {.closure.} =
echo "ugha"
proc takeCdecl(p: proc (x: int) {.cdecl.}) = nil
proc takeCdecl(p: proc (x: int) {.cdecl.}) = discard
takeCDecl(ugh[int])

View File

@@ -11,6 +11,6 @@ import sets
var intset = initSet[int]()
proc func*[T](a: T) =
proc fn*[T](a: T) =
if a in intset: echo("true")
else: echo("false")

View File

@@ -7,4 +7,4 @@ import mdotlookup
foo(7)
# bug #1444
func(4)
fn(4)

View File

@@ -1,6 +1,7 @@
discard """
output: "1.1000000000000001e+00 11"
ccodecheck: "!@'ClEnv'"
disabled: "true"
"""
proc p[T](a, b: T): T

View File

@@ -8,22 +8,22 @@ type
b: proc(val: T) {.thread.}
proc handleThreadFunc(arg: TThreadFuncArgs[int]){.thread.} =
var func = arg.a
var fn = arg.a
var callback = arg.b
var output = func()
var output = fn()
callback(output)
proc `@||->`*[T](func: proc(): T {.thread.},
proc `@||->`*[T](fn: proc(): T {.thread.},
callback: proc(val: T){.thread.}): TThread[TThreadFuncArgs[T]] =
var thr: TThread[TThreadFuncArgs[T]]
var args: TThreadFuncArgs[T]
args.a = func
args.a = fn
args.b = callback
createThread(thr, handleThreadFunc, args)
return thr
proc `||->`*[T](func: proc(): T{.thread.}, callback: proc(val: T){.thread.}) =
discard func @||-> callback
proc `||->`*[T](fn: proc(): T{.thread.}, callback: proc(val: T){.thread.}) =
discard fn @||-> callback
when isMainModule:
import os

View File

@@ -35,9 +35,9 @@ echo noParams(() => 3)
echo doWithOneAndTwo((x, y) => x + y)
noReturn(() -> void => echo("noReturn"))
noReturn((() -> void) => echo("noReturn"))
proc pass2(f: (int, int) -> int): (int) -> int =
(x: int) -> int => f(2, x)
((x: int) -> int) => f(2, x)
echo pass2((x, y) => x + y)(4)