> isa isn't a very motivating example
sure, but I was at least referring to title of the thread `Statically Check If
An Object Is A Subtype Of Another Object`, for which `is` is enough.
Instead of common ancestor, a more interesting primitive (on which common
ancestor can be built
`isa` isn't a very motivation example, how about calculating the common
ancestor of two different object hierarchies?
import macros, options
type
R = object of RootObj
Parent[T] = object of R # <-- branch of R
R1 = object of R # <-- another branch of R
` Foo = object of RootObj type Foo2 = object of Foo type Foo3 = object static:
doAssert Foo2 is Foo doAssert Foo isnot Foo2 doAssert Foo3 isnot Foo `
Run
Hi, Just wanted to share a little compile time function I wrote to statically
get an object's hierarchy. It can be used, for example, to determine if two
types have a child/parent relationship:
import macros
type
R = object of RootObj
Parent[T] = object of R