Easy to say "monomorphization is awful and Rust should never have done it", harder to say "I want all generic functions to be compiled to bytecode and to embed a Rust interpreter in every binary".
Could you explain more why it needs an interpreter and not "just" abstract (via vtable) over all the type things the code depends on (assuming data layout was still monomorphized)? E.g. ask vtable for size, copy function etc. What am I missing?
-
-
Because doing so is a giant mess. I wrote a lot of that code early on. I highly suspect that if we did it again it would be just as slow as interpreting the whole function.
-
I'm not 100% sure but I believe C# does it that way for reference types (i.e. size is the same, but any behavior gets forwarded via the interface). They don't do it that way for value types (where size can differ), so maybe that's a clue.
- Još 6 drugih odgovora
Novi razgovor -
Čini se da učitavanje traje već neko vrijeme.
Twitter je možda preopterećen ili ima kratkotrajnih poteškoća u radu. Pokušajte ponovno ili potražite dodatne informacije u odjeljku Status Twittera.