3 ms·
Swift takes this approach: monomorphisation is an implementation detail/optimisation. In languages like Rust and Swift where values don't have a uniform repres
by dbaupp 7y ago
Swift takes this approach: monomorphisation is an implementation detail/optimisation.
In languages like Rust and Swift where values don't have a uniform representation (that is, not always a pointer), this takes a lot of infastructure, and a lot of performance/optimiser work to get reasonable performance for common code: the Swift compiler has quite a bit of code devoted to making generically-types values behave mostly like statically-typed ones, with minimal performance cliffs.
Rust's approach is that this sort of vtable-/dictionary-passing has to be done explicitly (with a trait object), and such values have restrictions.