Hacker News new | ask | show | jobs
by aw1621107 10 days ago
I'm not super familiar with Lua so just to make sure I'm understanding you correctly are you referring to to-be-closed variables?

If so, I think the difference is that in C++/Rust RAII is the default and is quite pervasive as a result. To-be-closed variables seem like IDisposable in C# or try-with-resources in Java in that they allow the programmer to use RAII-like semantics but are opt-in.

1 comments

yes, just like in Rust, where Drop and constructors are optional idioms.
Manually implementing the Drop trait, perhaps, but the same can't be said for the drop operation, which you always get at the end of scope unless you opt out (which is very much a rare thing to do).