On 08/04/2012 11:58 AM, Daniel Patterson wrote:
You get the default param behavior, without the magic of overloading,
and it is clear from application what you are doing. This costs one
line of code, and having a separate name for the defaulted version…

Yes. This should be plan A for Rust programmers; plan B is method chaining :)

As an aside, the prevailing Rust style is clarity over cleverness, even if that results in a little less flexibility. For example, our map function in the standard library isn't as flexible as it could be; you can't map from a mutable vector to an immutable one or from an immutable vector to a mutable one with one function. Scala's map function does let you do that, and we could conceivably have duplicated that functionality with traits. But we really wanted the signature of the map function to be:

    fn map<T,U>(v: [T], f: &fn(T)->U) -> [U]

Instead of something more complicated.

As for named and optional parameters, I'm not opposed to them if they prove necessary, but my thinking right now is that they're not a version 1.0 feature.

Patrick
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to