2 ms·
Type 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 f
by codeflo 4y ago
Type 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.