I'd like to be able to compare two typedesc in a template to see if they're referencing the same type (or at least have the same type name) but am not sure how. The ==
operator doesn't allow this.
type
Foo = object
Bar = object
template test(a, b: expr): bool =
a == b
echo test(Foo, Foo)
echo test(Foo, Bar)
It gives me this:
Error: type mismatch: got (typedesc[Foo], typedesc[Foo])
How can this be done?
The
is
operator helps: http://nim-lang.org/docs/manual.html#generics-is-operator