7 ms·
Yes you have it right, `unwrap()` is equivalent to `%%`. It will panic if the result is an error. Error values under the hood are just unsigned integers and ar
by tiehuis 9y ago
Yes you have it right, `unwrap()` is equivalent to `%%`. It will panic if the result is an error.
Error values under the hood are just unsigned integers and are returned on the stack. In fact, the granularity at which allocators are exposed in the stdlib makes any possible dynamic allocation very explicit in the language.
This link [1] provides an overview of errors and some of the surrounding control flow.
[1]: http://ziglang.org/documentation/#errors http://ziglang.org/documentation/#errors
- bluejekyll 9y agoAh. Thanks for the link. I didn't see anything that section talk about passing values with the Errors, based on your comment, is that even possible? If you had an error you wished to pass a reason string for, would you need to use a global static or something?
- tiehuis 9y agoNot with the builtin error type. Its pretty much analogous to a c error code. If you wanted to send data you would need some other means like you suggest. I'd be interested in finding an ergonomic solution to this but it probably wouldn't be at the language level.