That isn't exactly what I'm looking for, but anyway thank you.
I found that this works (need additional brackets around the definition of
proc):
type
BinaryTree[V; compare: static[proc(a, b: int): bool]] = object
var b: BinaryTree[int, proc(a, b: int): bool = a < b]
echo b.compare(10, 20);
Run
and this doesn't:
type
BinaryTree[V; compare: static[proc(a, b: V): bool]] = object
var b: BinaryTree[int, proc(a, b: int): bool = a < b]
echo b.compare(10, 20);
Run
Simplified version:
type Foo[T] = object
type Bar[T; F: static[Foo[T]]] = object
var bar: Bar[int, Foo[int]()]
Run
This causes an ICE (internal compiler error):
type Vector[T; N: int] = object
data: array[N, T]
var v: Vector[int, 3]
Run
fatal.nim(39) sysFatal
Error: unhandled exception: int128.nim(72, 11) `arg.sdata(2) == 0` out of
range [AssertionError]
Run
I also believe that generic parameters should be static by default:
type Foo[T, N: int] should be treated as type Foo[T, N: static int]