On 2014-05-30, at 2:48, comex <com...@gmail.com> wrote:

> On Thu, May 29, 2014 at 7:01 PM, Tommi <rusty.ga...@icloud.com> wrote:
>> The lack of function overloading forces us to have two differently named 
>> functions, say `foo_a` and `foo_b`, and the programmer has to keep in mind 
>> that if he wants the optimized algorithm, then he needs to call `foo_b` 
>> (instead of `foo_a`) if his argument implements `B`.
> 
> I would consider this usually an upside, because this way the
> programmer knows whether the fast or slow version is being used, and
> that calling the slow version may be a hazard to be improved by
> refactoring the code to implement B.  It may occasionally be a
> downside.

Assuming the programmer knows both the type of the argument and the manner in 
which the type of the argument determines which algorithm ends up being used, 
then the programmer knows whether the regular or the optimized version of the 
algorithm is being used also in the case of `foo` being overloaded.

And if the programmer doesn't know the type of the argument (the type is a 
template parameter for example), then he *really* needs the overloaded `foo`.

_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to