3 ms·
Actually, I think types are erased in most typed languages, unless they support runtime reflection.
by wtetzner 4y ago
Actually, I think types are erased in most typed languages, unless they support runtime reflection.
- codeflo 4y agoType erasure is a specific compilation technique, it means more than a lack of introspection capabilities. In most languages, a function taking a float and a function taking an int end up producing different compiler output (because they need to use different CPU registers). More to the point, this extends to generic/template functions with signatures like “void foo<T>(T arg)”, which then need to be monomorphized, that is, copied for each instantiation. Languages with type erasure simply drop the type argument instead of instantiating it.