7 ms·
My understanding is that "ad-hoc" in this context means that you are not defining a single generic implementation but adding individual impls for specific types
by demurgos 1y ago
My understanding is that "ad-hoc" in this context means that you are not defining a single generic implementation but adding individual impls for specific types. There's no fundamental difference between Java's overloading and Rust's implicitly inferred trait implementations in my opinion.
Rust's implementation is more orthogonal, so specifying which impl you want explicitly does not require special syntax. It's also based on traits so you'd have to use a non-idiomatic style if you wanted to use overloading as pervasively as in Java. But are those really such big differences? See my reply to the original where I post an example using Rust nightly that is very close to overloading in other languages.
- tavianator 1y agoThey were referencing the title of a specific paper, which invented type classes: https://dl.acm.org/doi/10.1145/75277.75283 https://dl.acm.org/doi/10.1145/75277.75283
- demurgos 1y agoThank you, I did not know this paper and totally missed the reference.