[rust-dev] std::num::pow() is inadequate / language concepts

Patrick Walton pcwalton at mozilla.com
Fri Jul 25 15:22:27 PDT 2014

On 7/25/14 3:20 PM, Josh Haberman wrote:
> Got it. So the "ad hoc" part refers to having a template parameter, but
> not being able to check its capabilities/interface at template
> parsing/typechecking time, it sounds like?

Right. (The term comes from "Making Ad-Hoc Polymorphism Less Ad-Hoc", 
which is the seminal paper on typeclasses.)

> How does the trait/concept approach preclude template specialization?
> Each template specialization could be independently type-checked, but
> the most specialized one could be selected at instantiation time. Or is
> this considered "overloading" and discarded because of the extra
> complexity? I guess it could be complicated to define which was "most
> specialized."

Yeah, that's the complexity. Some GHC language extensions do allow 
something like template specialization, but it's considered very 
experimental. I'd like to see if things like associated types get us 
most of the way there without the difficulties of specialization.


More information about the Rust-dev mailing list