4 ms·
Zig is all about making things explicit. Destructors are hidden code. I presume there will be an application level tracking of lifetime.
by justinhj 1y ago
Zig is all about making things explicit. Destructors are hidden code.
I presume there will be an application level tracking of lifetime.
- deleted 1y ago[deleted]
- maleldil 1y agoYes, which is why Zig can't have RAII. Zig initialisation and destruction are fundamentally different to how RAII works in other languages. That's not a negative point; it's just how Zig is. But it's not RAII.
- justinhj 1y agoYou are right. It seems the developer agrees and has changed the README
- cakealert 1y agoIt's explicit opt in RAII, you opt in by using a defer.
- ioasuncvinvaer 1y agofree is an explicit opt-in garbage collector.
- lenkite 1y agoRAII, which stands for Resource Acquisition Is Initialization, is a programming technique in which a resource's lifetime is tied to an object's lifespan. An explicit defer does not fit this paradigm.