Why does D rely on a GC?

Nick Treleaven via Digitalmars-d digitalmars-d at puremagic.com
Tue Aug 19 08:10:07 PDT 2014


On 19/08/2014 15:09, Andrei Alexandrescu wrote:
>> There I fully agree. If they don't improve lifetime's usability, I don't
>> see Rust being adopted by average developers.
>
> Could you please substantiate this with a couple of examples?

Here's an example I ran into playing with the last release. Maybe I'm 
doing something wrong though:

fn main()
{
     let mut x:uint = 0u;
     let f = ||x += 1;	// closure borrows x
     if x == 1 {return}  // error: cannot use `x` because it was mutably 
borrowed
     f();
}

This seems unnecessarily restrictive.


More information about the Digitalmars-d mailing list