On Nov 20, 2013, at 6:21 PM, Ziad Hatahet <[email protected]> wrote:

> On Wed, Nov 20, 2013 at 5:58 PM, Tommi <[email protected]> wrote:
> Here's why: if you make a call foo(arg) and never use arg after that, then 
> you don't care if arg gets moved or borrowed. And if you try to use arg 
> afterwards and foodid in fact move it previously, then your IDE is going to 
> tell you about it by drawing a red squiggly line under that incorrect use of 
> arg.
> 
> 
> This is from the point of view of the person writing the code. What about 
> someone reading the code? He/she would either have to go through the 
> remainder of the function/scope to make sure that `arg` was not being used 
> (if it were, then it was a borrow, otherwise, it could have been either a 
> borrow or a move); or they would have to look at the signature of `foo()`; as 
> opposed to just being able to tell right there at the call site.

Why does the reader particularly care? Presumably the code compiles (otherwise 
I have to ask why they're reading broken code, which is broken in a way that 
the compiler would trivially explain), so either it's moved and the arg isn't 
used again, or it's borrowed. It only really matters if the reader wants to 
subsequently modify the code, at which point they're now the person writing the 
code. And we get back to Tommi's point that the compiler (or, ideally, an IDE) 
will tell you if you try and use a moved value.

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

Reply via email to