generic types can be used like type classes. distinct can be applied to type classes.

This commit is contained in:
Zahary Karadjov 2012-03-25 20:55:21 +03:00
commit bc2eb0ea9b
11 changed files with 147 additions and 79 deletions

View file

@ -0,0 +1,13 @@
import unittest
proc concat(a, b): string =
result = $a & $b
test "if proc param types are not supplied, the params are assumed to be generic":
check concat(1, "test") == "1test"
check concat(1, 20) == "120"
check concat("foo", "bar") == "foobar"
test "explicit param types can still be specified":
check concat[cstring, cstring]("x", "y") == "xy"