Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Rust's `drop<T>(_: T)` function is really neat in that it's basically an empty function. Since ownership of the argument moves to the drop function it explicitly leaves scope and gets torn down.

You can do something similar for go where you have a function that marks your locally-scoped variable dead, the compiler can track to make sure you don't use it afterwards, and if it's not the last reference to the underlying, it's not deallocated. If it is, it gets culled immediately.



The “toilet closure” also works.

  |_|()




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: