Nimony

The road to Nim 3

typetraits

nimony/lib/std/typetraits.nim

Compile-time reflection on types.

Nim 2 implemented these as {.magic: "TypeTrait".} procs, i.e. as compiler built-ins. Nimony implements them as ordinary template plugins: the compiler hands the plugin the argument type as NIF, the plugin transforms that tree, and the result is re-checked in type position. Nothing here is known to the compiler.

A plugin runs in its own process and so cannot resolve a symbol on its own. It does not have to: it asks. When the plugin meets a nominal type it has not been given, it returns needTypes(sym), the compiler appends that declaration to its second input and runs it again. Nothing is shipped that was not asked for.

Unstable API.