3 ms·
> Zig errors do not have a payload component because Zig is very strict about not having hidden allocations That's likely not the reason. The above article lin
by alpaca128 4y ago
> Zig errors do not have a payload component because Zig is very strict about not having hidden allocations
That's likely not the reason. The above article links to a Github issue in which people have been discussing various proposals for handling payloads since 2019, and not a single time it was ruled out because of allocations as those could be handled the same way as anywhere else.
Not to mention in many situations an error payload wouldn't necessitate an allocation. For example just allowing a single integer as payload in a parser would already be a huge help. If the language's standard library won't even return a position for JSON parsing errors I'd consider that a problem. Imho it is a mistake to give errors special syntax features without any way of expanding them.