type
T = Rootobj
T2 = object of T
i: int
var t: T2
proc a(o: T) =
echo "proc a"
#template a(o: expr) =
# echo "template a"
a(t)
Output isproc a
When I uncomment the template, I get
template a
That may be OK -- personally I would like proc invocation better. Months ago that behaviour gave me some trouble, the template was a plain cast, so I got that cast instead of the desired proc call.
That's not because templates have priority over procs, but because of argument types. Say, if you have 2 procs, 1 taking T and another - any (procs cannot take expr), then the 2nd (with any) will be called. The same if the 1st (with T) is a template, or if both are templates, or if both are templates and the 2nd is expr. In all these cases not "template vs. proc" determines the choice.
Though it seems to me that T should be preferred over expr as less specific.