Too long already but I reread your post and realized I got a bit lost in the weeds.
What I believe you were actually asking for was a way to provide an API to get out these compile time values. The actual answer is, they don't belong to the variable, they belong to the type. They are like static class variables in C++ or Java. So the API should be on the type, not the instance. func idea0[T:Ix](t:typedesc[T]):int = T.N echo foo(idea0(z.typeof)) Run But maybe you disagree, maybe the API needs to be on a runtime instance. And the result needs to be in a compile time context. In that case, you need to get that variable into a compile time context, and yes, the cleanest way to do that is with a template. Templates are great, use templates. But also, do reconsider your idea that `type.member` is somehow hacky or magical.