←back to thread

517 points bkolobara | 1 comments | | HN request time: 0s | source
Show context
aeve890 ◴[] No.45042188[source]
>The code will compile just fine. The Zig compiler will generate a new number for each unique 'error.*'

This is wild. I assume there's at least the tooling to catch this kind of errors right?

replies(3): >>45042403 #>>45042586 #>>45050319 #
TUSF ◴[] No.45042403[source]
There's no special tooling to catch this, because nobody catches an error with if-else—it's simply not idiomatic. Everyone uses switch statements in the catch block, and I've never seen anybody using anything other than switch, when catching an error.
replies(4): >>45042474 #>>45042605 #>>45043295 #>>45043644 #
dminik ◴[] No.45043644[source]
Both the Zig standard library as well as several third party projects do check errors like this.

I already commented on Zig compiler/stdlib code itself, but here's Tigerbeetle and Bun, the two biggest(?) Zig codebases:

https://github.com/search?q=repo%3Atigerbeetle%2Ftigerbeetle...

https://github.com/search?q=repo%3Aoven-sh%2Fbun%20%22%3D%3D...

replies(1): >>45045893 #
dminik ◴[] No.45045893[source]
Ok, while it's cool that the TigerBeetle link now shows no matches (down from two) the comment now feels wrong. Anyways, you guys left in the `!= error.` checks, so here's some snapshots that hopefully won't be invalidated :P

https://github.com/tigerbeetle/tigerbeetle/blob/b173fdc82700...

https://github.com/tigerbeetle/tigerbeetle/blob/b173fdc82700... (different file, same check.)

replies(1): >>45050215 #
1. matklad ◴[] No.45050215{3}[source]
Good catch of != thanks!