Would like to see ref and out required for function calls

Ziad Hatahet hatahet at gmail.com
Tue Sep 18 14:26:55 PDT 2012


On Mon, Sep 10, 2012 at 1:36 PM, Timon Gehr <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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20120918/535e5c3a/attachment.html>


More information about the Digitalmars-d mailing list