On 10/18/2013 11:14 AM, Daniel Micay wrote:
On Fri, Oct 18, 2013 at 12:09 PM, Jack Moffitt <[email protected]
<mailto:[email protected]>> wrote:
In the latest Rust upgrade for Servo, I noticed that the path API is
now mutate-in-place instead of return a new path. It used to be that
path.push("foo") gave you a new path with an extra component, but now
path.push("foo") returns () and mutates the path in place.
I liked the old API better. I realize this is probably more consistent
with std::vec, and consistency is good. I thought I'd bring this up to
see what other people thought as a lot of the APIs are getting
rewritten lately and I haven't seen any concrete guidelines on what
they should be.
If we decide that both API styles are good to have, what should the
naming convention be for the functional vs. mutable ones? Ruby,
Scheme, and Clojure use `!` to denote the in-place mutation ones, but
that syntax is for macros in rust.
jack.
I think an immutable version should only be exposed if it's as
efficient as operating in-place. For containers, I really don't want
to have APIs that exist only to make allocating a whole new container
and copying over more convenient. It's harder to write efficient code
when inefficient code looks more idiomatic.
Efficiency isn't the only design consideration and not always the most
important, even in Rust. I imagine that path manipulation is not a
performance bottleneck for most applications.
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev