4 ms·
class Type { int size; } and then add methods for every conceivable type-dependent operation. Alternately, a sumtype or enum+pointer will also do. Then you just
by FeepingCreature 3y ago
class Type { int size; } and then add methods for every conceivable type-dependent operation. Alternately, a sumtype or enum+pointer will also do. Then you just attach a type to every expression. At least, that's how you do it in a "forward-typed" language like C. In a language like Haskell it's a bit harder because your type assignment is a full graph, not a DAG like in C.