logoalt Hacker News

orf • today at 7:47 AM • 3 replies • view on HN

The linked thread here[1] is… illuminating. The Zig stdlib seems pretty buggy, and the much applauded IO interfaces seem to be struggling with cancellation. The BDFL doesn’t seem to have much to say other than “brush your teeth”

1. https://ziggit.dev/t/making-it-harder-to-swallow-error-cance...


Replies

lukaslalinsky • today at 8:03 AM

No, that's not the best description. The Io interface is actually one of the best cancellation stories out there. If you combine it with defer/errdefer, you get safer cancellation guarantees than you have in async Rust (you can do async "drop" for example). The only problematic part is the interaction between the Reader/Writer interface and the Io interface, with regards to error handling.

➕ show 1 reply
brodo • today at 9:08 AM

The answer from Andrew sounds like that because there is a history between people from the core team and lalinsky.

➕ show 1 reply
ptsneves • today at 8:56 AM

Not a zig person, but the post you linked has a good counter example on why the proposal for adding cancellation to the interface is bad: You would be forcing cancellation semantics on interfaces that might not want nor be able to provide one. Forcing a new method because the libraries are not well designed does not seem right for me. Maybe another solutions is available, but that is not one.

I get the pain, but the answer from Scott Redig totally makes sense. I am not sure what is worse: Libraries swallowing cancelled() or libraries lying that they support cancelled.

➕ show 1 reply