Skip to content
This repository has been archived by the owner on Jun 6, 2021. It is now read-only.

Note: Type Information Storage

Alex Rønne Petersen edited this page Jun 6, 2013 · 8 revisions

Type information for the various types used in Flect programs is stored in bundles along with regular data declared by the programmer. The compiler only emits type information lazily, when needed. Specifically, type information is emitted if:

  • The @ operator is used to create a box of some data.
  • The meta type T expression is used and the result needs to be compiled into the bundle.
  • Debugging is enabled at compile time.

The reason that the @ operator needs to emit type information is that the GC needs to know the shape of the data that is being boxed in order to efficiently and precisely analyze it. The type expression only causes type information to be compiled in if it is used in a run-time evaluation context (e.g. in a regular function). Debugging requires emitting full type information for every variable so that the debugger API can provide it.

The language does not guarantee that the identity meta type T === meta type T (where meta type T returns &core::meta::TypeInfo) holds. This is so that we can avoid complex ABI issues with type information symbol names, visibility, and linkage. The right thing to do is to treat the information returned by meta type T as structural data instead. The comparison meta type T == meta type T will do the right thing (but is a bit slower than an identity comparison).

Given the above guarantees (and lack thereof), the compiler is free to emit type information wherever it wants in a bundle, and with whatever symbol name it wants (as long as the symbol is private and it doesn't clash with another symbol in the bundle).

The exact format used for type information storage is implementation-defined. The only requirement from the specification is that whenever type information is accessed, it is a proper core::meta::TypeInfo value.

Clone this wiki locally