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

> RAII is great; I wish they'd use some light (optional) RAII for strings and containers etc.

Is it not possible to build a wrapper that does this? It seems like it should be.



It is. I definitely agree that strings in Zig can be tedious, but the upside is that if you need it, you can build a string library that does everything you want it to do, in the way you want.

For comparison, while Rust offers a very rich string library, it's also very strict about what you can/cannot do with strings, so if your use case falls outside of that you're out of luck. With Zig, you can pretty easily roll your own and make it do what you want. (and when Zig is post 1.0, I imagine there will be some very nice pre-made string libraries by the community etc.)


You can also roll your own strings in Rust just fine. Take the bstr crate, for example.


Library interoperability becomes a PITA when everyone builds their own string library. Then you need conversion libraries.


But I don't think you can implement RAII in Zig?




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

Search: