Re:Removing garbage collection from the Rust language
by dbaupp on Monday June 03, 2013 @07:14AM
(#5812536)
> it's the only pointer allowed to that memory
Not quite true with borrowing (i.e. & and &mut), which allows a temporary pointer to the memory to be created. Unlike C++ however, the compiler makes sure all borrows are safe via a fairly intricate borrow checker, that guarantees (among other things) that the borrowed pointers don't outlive the original object. (i.e. no dangling references.)
Re:Removing garbage collection from the Rust language
by steveklabnik on Monday June 03, 2013 @07:30AM
(#5812583)
Ah! Yes. That's what I get for posting at 3am, thank you. :)
I am not mega familiar with all of the details of {unique,scoped}_ptr, but my current understanding of ~ is this: basically, the compiler inserts a malloc before and a free after something declared with ~ goes into and out of scope, and it's the only pointer allowed to that memory.