2 ms·
> 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 exce
by 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-...