Dave Herman's recent talk in Rust said that they borrowed this property from C++. I couldn't find anything around the topic. Can somebody please explain what monomorphisation means?
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
- What uses more memory in c++? An 2 ints or 2 funct
相关文章
- How can I convert a f64 to f32 and get the closest
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- What is a good way of cleaning up after a unit tes
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
Not sure if anyone is still looking at this, but the rust documentation actually does mention how it achieves no cost abstraction through this process:
https://doc.rust-lang.org/book/2018-edition/ch10-01-syntax.html
Monomorphization means generating specialized versions of generic functions. If I write a function that extracts the first element of any pair:
and then I call this function twice:
The compiler will generate two versions of
first()
, one specialized to pairs of integers and one specialized to pairs of strings.The name derives from the programming language term "polymorphism" — meaning one function that can deal with many types of data. Monomorphization is the conversion from polymorphic to monomorphic code.
Not sure about this; could you link to the talk? It might have been an offhanded remark.
Herman might have coined a term for something like template specialization, which generates types/objects which are mutually unrelated (not-polymorphic or "monomorphic") from the template, which is a polymorphic structure.