3 ms·
So... like checked exceptions (e.g. Java needs to declare those in the signature, and they are an integral part of said signature). The more I hear about how Z
by hota_mazi 5y ago
So... like checked exceptions (e.g. Java needs to declare those in the signature, and they are an integral part of said signature).
The more I hear about how Zig implements it, the more it is exactly like exceptions.
- von_lohengramm 5y agoIt is different in implementation, for better or worse. Instead of stack unwinding, it's a part of the return value.
- masklinn 5y ago> The more I hear about how Zig implements it, the more it is exactly like exceptions. It's exactly like exceptions aside from all the problematic bits of exceptions: * it is very explicit * it is much easier to interact with * it can be abstracted over (since a "result" is a reified value of a known type) * it supports but is not over-optimised for happy path or split-path scenarios * it doesn't require separate allocations or RTTI * it has a much more uniform cost model That doesn't necessarily mean it's the right system for what you usually work with, but it's a really nice way to do error handling. For an expansion of this, Brian Cantrill has a paean to this error handling style in his "falling in love with rust"[0], I can't direct-link the section but it's "1. Rust’s error handling is beautiful". [0] http://dtrace.org/blogs/bmc/2018/09/18/falling-in-love-with-rust/ http://dtrace.org/blogs/bmc/2018/09/18/falling-in-love-with-...