Why should it be surprising? Procedure calls and field accesses in generics 
aren't resolved until instantiation time. What if wuff was a field of 'a'? 
Anyway, if by 'inlining' you mean, 'can the Nim compiler/backend compiler 
inline generics', then yes, it can be inlined.

I don't quite understand your last question. If there is a generic cmp[T](x, y: 
T) that applies to all objects, and a more specific cmp(x, y: Foo) defined in 
the current module/an imported module, the more specific procedure will take 
precedence during the resolution process.

Looking at the algorithm module's 
[sort](http://nim-lang.org/docs/algorithm.html#sort,openArray\[T\],proc\(T,T\)) 
procedure, it looks like a sensible addition might be to have a 'sort' 
procedure which defaults to calling 'cmp' on the items, but the current 
implementation is ok. I wouldn't be surprised if a compile inlined any calls to 
'sort', detected the function pointer, and inlined the referenced function too.

Reply via email to