I am not sure if it is intentional, but it looks like a bug: Why is `table` here global? let table {.global.} = MethodTable( foo: proc (this:pointer):int = cast[ptr T](this).foo )
EDIT: Btw that is the same way I started. I wrote a version that works without macros, and then I wrote a marco that would generate all the parts that could be automated.