One of the cooler features of Nim that many doesnt know about is static introspection. Imagine you want to know the parent of type at compile time. There is no built in function for it, but no worries, it can be implemented like so:

1/2
#nimlang #gamedev #indiegamedev

Oct 10, 2023 · 2:44 PM UTC

1
3
11
929
Replying to @_jmgomez_
The key here is getImpl which retrieves the AST of a symbol, which is bound via bindSym. Then we just traverse the AST to find out what the parent type is
0
0
2
83
RepliesRelevant