Hello, I'm new to the language and I'm having a hard time understanding the types system and how they interact with generics (And sadly, there is no much stuff in the documentation to follow) For example, I would expect the following snippet to not even compile: import typetraits type TT[T] = ref object of RootObj val: T CB[T] = proc (v: T): void proc testGeneric[T](val: TT[T], cb: CB[T]): void = echo val.type.name echo $val.val var tt = new(TT[seq[string]]) echo tt.type.name tt.testGeneric( proc (v: int): void = echo $v )
However, it compiles and runs. And also, I would expect the type of tt to be the same when outputted, instead the output is: TT[seq[string]] TT[system.int] 0 Can somebody help me with information as why this is not failing to compile, why it is choosing to specialize testGeneric with _int_ (instead of finding a conflict of different 'T's), and why it accepts to pass a TT[seq[string]] to a function expecting TT[int]? Why type.name differs in both calls? Any insights are very much appreciated. Thanks.