On 7/21/14 8:49 AM, Tobias Müller wrote:
Patrick Walton <pcwal...@mozilla.com> wrote:
On 7/20/14 8:12 PM, David Henningsson wrote:
  From a language design perspective, maybe it would be more intuitive to
have different syntaxes for copy and move, like:

As a rust newbie, that aspect aways makes me a bit nervous. Two quite
different operations with the same syntax and and simply changing a detail
in the struct can be enough to switch between the two.

This is the reason for Opt-In Built-In Traits.

AFAIK this also was one of the reasons (if not _the_ reason) why
std::auto_ptr was deprecated in C++.

No, `auto_ptr` was deprecated because it copies, not moves, making it hard to sensibly use in containers (among other things).

Comparisons between C++ aren't really relevant anyway because the compiler catches any use-after-move at *compile time*, rather than at runtime. This means that mistaking the two doesn't cause any harm:

* Causing a move when you thought you were copying results in a compiler error.

* Causing a copy when you thought you were moving is harmless, as any implicit copy in Rust has *exactly the same runtime semantics* as a move, except that the compiler prevents you from using the value again.

Again, we had that world before. It was extremely annoying to write "move" all over the place. Be careful what you wish for.

Patrick

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

Reply via email to