Closed krux02 closed 5 years ago
nice, I hope in the future NimNode
could be converted back to typedesc
at compile time.
What do you mean with "NimNode
could be converted back to typedesc
at compile time"? Here is a length RFC about the reason for this change: https://github.com/nim-lang/RFCs/issues/148. In short, NimNode
is what you really want to use in macros. Internally (in the compiler) the NimNode and the typedesc has the exact same representation. That is also why this change is so minimal. But NimNode can be traversed, and most importantly, you can put a NimNode
into the ast. You can't do this with typedesc
.
I'm not talking about using typedesc
in AST, but using type as value during VM execution, see nim-lang/Nim#6785
Well, even if you could get typedesc
from a NimNode
, it cannot work like in the mentioned issue. The mentioned issues depends on static overloading. The returned typedesc
from a NimNode
would not have this distinction. I will write in the issue about it as well.
typedesc is now passed to macros as
NimNode
, apart from that it works as before. This minimal code change should work for both old and new version of Nim. In the future| typedesc
part can be removed.This change is necesary to make the make the CI in this PR green: https://github.com/nim-lang/Nim/pull/11400