News for hackers. Stuff that matters.
Re:Rust: Dropping heavy things in another thread can make yo... by estebank on Saturday May 30, 2020 @02:57PM (#23363647)
In Rust you could just call `mem::forget` on whatever heavy thing that you're no longer using is before it would get dropped, but then the programmer is effectively responsible for that memory leak not becoming a problematic leak during refactors.

Edit: this will also break any code that relies on Drop being called for clean up, but that is already a "suspect"/incorrect pattern because there are no assurances that it will ever run.

Re:Rust: Dropping heavy things in another thread can make yo... by kd5bjo on Saturday May 30, 2020 @04:45PM (#23364545)
> There are no assurances that it will ever run.

Yes and no. Whenever control leaves a code block, Rust automatically calls the drop() method of all values still owned by that block. There is no guarantee that control will exit every block (cf. Turing), but a moderately exceptional circumstance needs to occur for this not to happen, like an infinite loop.

Re:Rust: Dropping heavy things in another thread can make yo... by rcxdude on Saturday May 30, 2020 @05:35PM (#23364974)
There's also no guarantee the object won't be moved elsewhere, including into a context which never gets freed (for example, you can construct mem::forget using entirely safe code by forming a cycle of reference-counted boxes). That said, Rust has support for such a concept through the Pin trait (which essentially guarantees an object will not get moved until it is 'Unpinned').
Re:Rust: Dropping heavy things in another thread can make yo... by mcguire on Saturday May 30, 2020 @03:34PM (#23363917)
Isn't that a problem for the RAII approach?