jangko / msgpack4nim

MessagePack serializer/deserializer implementation for Nim / msgpack.org[Nim]
http://msgpack.org/
119 stars 21 forks source link

compatibility #33

Closed krux02 closed 5 years ago

krux02 commented 5 years ago

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

jangko commented 5 years ago

nice, I hope in the future NimNode could be converted back to typedesc at compile time.

krux02 commented 5 years ago

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.

jangko commented 5 years ago

I'm not talking about using typedesc in AST, but using type as value during VM execution, see nim-lang/Nim#6785

krux02 commented 5 years ago

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.