4 ms·
The types created in compile-time code are just as "real" as the types you declare in source code. All types become values at compile time. When you write a co
by skybrian 4y ago
The types created in compile-time code are just as "real" as the types you declare in source code.
All types become values at compile time. When you write a compiler, the parser creates ordinary values, perhaps instances of a Type type. The type-checking code operates on these values to find errors according to the rules of type theory. Compile-time functions are a way of calling user-defined code in the compiler, much like a macro but saner, and they can create types that can be used in declarations, verified by the type checker, and used as input to the code generator.
(Reflective use of runtime types in languages like C#, Java, or Go is different.)
- still_grokking 4y agoEven you almost didn't say anything wrong here there is a key misunderstanding: The term "type theory", which I've used and to which I referred (and which you've picked up), is a technical term form math. Languages like C# or Zig are not based on type theory. What is called "types" in those languages has (mostly) no relation to type theory. Those "types" are (mostly) regular values when looked at them through the type theory lens.