Would like to see ref and out required for function calls

Timon Gehr timon.gehr at gmx.ch
Wed Sep 19 02:03:21 PDT 2012


On 09/18/2012 11:26 PM, Ziad Hatahet wrote:
> On Mon, Sep 10, 2012 at 1:36 PM, Timon Gehr <timon.gehr at gmx.ch
> <mailto:timon.gehr at gmx.ch>> wrote:
>
>
>     Yes, Go uses explicit pointer types.
>     Regarding Rust, you are wrong.
>     I have built the latest Rust compiler.
>
>     import io;
>
>     fn modify(&a:int){
>          a = 2;
>     }
>     fn swap<T>(&a:T,&b:T){
>         let tmp<-a;
>         a<-b;
>         b<-tmp;
>     }
>
>
> The `fn foo(&a: T)` syntax is being deprecated in favor of `fn foo(a:
> &mut T)`.
>
> So your modify function becomes: `fn modify(a: &mut int)`, and gets
> called as `modify(&mut a)`.
>
> Your swap function becomes `fn swap<T>(a: &mut T, b: &mut T)` and gets
> called as `swap(&mut a, &mut b)`.
>
> So effectively, Rust also opted for explicit ref at the call site.
>
> --
> Ziad

I see. Thank you for the clarification.


More information about the Digitalmars-d mailing list