timotheecour / Nim

Nim is a compiled, garbage-collected systems programming language with a design that focuses on efficiency, expressiveness, and elegance (in that order of priority).
http://nim-lang.org/
Other
2 stars 0 forks source link

rtti: getDynamicTypeInfo #573

Open timotheecour opened 3 years ago

timotheecour commented 3 years ago

refs:

Hi! Noob question: having a ref to a "base" type, (how) can I print the name of the "runtime" type it points to?

(question was asked in gitter)

akavel commented 3 years ago

For the record/background, some more context is available in the irc log of the conversation (see also further down).

timotheecour commented 3 years ago
proc getDynamicTypeInfo[T](x: T): PNimTypeV2 {.magic: "GetTypeInfoV2", noSideEffect, locks: 0.}

seems super relevant; it's available only for --gc:arc though; and for some reason, name is nil, but not other fields

timotheecour commented 3 years ago

@akavel see https://github.com/nim-lang/Nim/pull/16963