Re:Why is Zig so Cool?
by lenkite on Saturday November 08, 2025 @01:54AM
(#45854704)
I would like a language to support both defer and C++ style destructors / Rust Drop. There are good use-cases for having both. For things like a mutex or straight-forward resource cleanup - having a bunch of brain-dead defer statements adds little value and only bloats unnecessary line count. Let the resource type handle its own release/cleanup at scope close. Code is made sweet, succinct and safe.
[ Parent
| on HN ]
In Rust, there’s a drop guard pattern to do this, which leverages the lazy execution of closure, checkout the scopeguard crate. C++ should be easy to do that too I think
Re:Why is Zig so Cool?
by 1718627440 on Saturday November 08, 2025 @06:58AM
(#45856057)
GNU C++?