News for hackers. Stuff that matters.
Re:Rust means never having to close a socket by tomp on Tuesday October 07, 2014 @12:52PM (#8422256)
I agree. Having files and sockets close automatically is a bad pattern. Ideally, in a language with linear types, the compiler would notify you of all resources that you didn't properly dispose of when they go out of scope - so, unless you return the handle or call `close(f)` at the end of the function, you'd get a compiler error. The compiler could also auto-insert `close()`/`dispose()` methods when they go out of scope, as is implemented in Rust using the Drop trait.

I don't know if Rust supports forcing explicit deallocation, but even if it doesn't, it's still an improvement compared to most GC-d languages.

Re:Rust means never having to close a socket by dkhenry on Tuesday October 07, 2014 @01:05PM (#8422343)
If I understand the borrowing and lifetime mechanisms of rust it would be trivial to have it say anything that has a lifetime that is active at the end of a scope is a compiler error.

It would almost be like how in c++ you can disable copying by setting all the copy constructors to delete and then the compiler will tell you if your accidentally making copy's of objects.

Re:Rust means never having to close a socket by tomp on Tuesday October 07, 2014 @01:08PM (#8422371)
I agree, it would probably be trivial. It's mostly a language/library design issue, not a type-systems research problem.
Re:Rust means never having to close a socket by steveklabnik on Tuesday October 07, 2014 @01:11PM (#8422400)
You're talking about linear types, Rust implements affine types. They're very similar.