4 ms·
I'm not speaking for Zig, but in principle errors are not values, and often have different control flow and sometimes even data flow constraints.
by naasking 2y ago
I'm not speaking for Zig, but in principle errors are not values, and often have different control flow and sometimes even data flow constraints.
- valenterry 2y agoCan you elaborate more?
- chrisco255 2y agoThey're enums. See: https://zig.guide/language-basics/errors https://zig.guide/language-basics/errors
- valenterry 2y agoThere it says "errors are values" so now that contradicts what OP said.
- chrisco255 2y agoI was generally responding to the whole thread and pointing to how Zig sees errors. Enums are a type of value, yes, but they're typically dealt with differently than other data types.
- naasking 2y agoI said I wasn't speaking for Zig specifically, just on general principle that errors are not really values. Many languages reify errors as values to avoid having different semantics for errors, but errors probably should have their own semantics. Zig seems to take a middle ground here, where errors are a special type of value but that still sort of has its own semantics.
- valenterry 2y ago> I said I wasn't speaking for Zig specifically Lol, you are right. My brain just skipped that part somehow.