On Sun, Apr 7, 2013 at 3:01 PM, Heri Sim <[email protected]> wrote:

>
> Passing in a stack-local variable to a function or closure (that
> requires arguments to be passed by reference), should not require the
> ampersand (&) in the caller. Why can't the compiler figure this out?
>
>
This is one of the features I really like about Rust. C++ and D took the
implicit approach to pass-by-reference, whereas languages like C# took the
explicit approach. Not too long ago, there was a thread on the D forums
arguing for making pass-by-reference explicit at the caller site. However,
it was too late to make such a backward incompatible change since it would
break a lot of code out there.

There is no option of having pass-by-reference in Go. You pass a pointer to
the struct, which also makes it explicit at the caller site. So in this
case, Rust is not dissimilar from Go.

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

Reply via email to