You CAN do error payloads in zig

  Рет қаралды 989

E-xyza

E-xyza

23 күн бұрын

How I do Error Payloads in Zig.
This is a response to chat in @ThePrimeagen 's video on Zig
• Is 2024 The Year Of Zig ?
Article covering the same subject:
zig.news/ityonemo/sneaky-erro...

Пікірлер: 7
@JacobDanton
@JacobDanton 12 күн бұрын
I appreciate the workaround, but that’s all it is. With this approach you: * can return an error without setting an error payload * can set an error payload without returning an error * do not have error payload types associated with the error and are tied to one type for all errors But I believe there is a GitHub issue where the Zig maintainers agreed they are adding error payloads eventually.
@iatheman
@iatheman 6 күн бұрын
The machine code responding to the payload needs is great and all. But writing and reading this kind of code isn't the best experience. I'd rather have payloads embedded in the error types if possible.
@CoolestPossibleName
@CoolestPossibleName 21 күн бұрын
I was watching that primeagen's on youtube, read that chat, and saw this video. The explanation you did with godbolt was great. Personally I think error payload is just unnecessary, at least in this particular example. The users of the function could read the document, understand the error better and handle it the way they want it. This feels like too much work.
@isaacyonemoto
@isaacyonemoto 20 күн бұрын
Agreed. too much for this example but if I made a "real-ish" example it would be too much code for a 10 minute video 😂 Imagine though for a parser, you could stash file/line/column in the payload.
@nathanfranck5822
@nathanfranck5822 13 күн бұрын
I ran into an issue recently where I wanted to get an error payload when parsing JSON. The std library in zig does have a way to get info about where the json parser failed though, so you can still extract something meaningful to dump in a log or on-screen, it's just not super convenient. Definitely most cases where you're getting an error, there's not going to be any meaningful payload that needs to be scraped together at runtime, and not having it as a convenient feature might prevent extra memory leaks when you're off the happy path... But it still seems a bit strange to not have it when tagged unions in zig already exist.
@codechapin
@codechapin 9 күн бұрын
@@nathanfranck5822is there a way to get logging from the std library?
@salim444
@salim444 16 күн бұрын
I searched for this video
but what is 'a lifetime?
12:20
leddoo
Рет қаралды 56 М.
Java 22 ... and beyond | Brian Goetz (Oracle)
43:05
JAX TV
Рет қаралды 2 М.
Ну Лилит))) прода в онк: завидные котики
00:51
Be kind🤝
00:22
ISSEI / いっせい
Рет қаралды 13 МЛН
100❤️
00:19
Nonomen ノノメン
Рет қаралды 36 МЛН
My Initial Impresson Of Go
12:39
TheVimeagen
Рет қаралды 59 М.
zig is the future of programming. here's why.
9:34
Low Level Learning
Рет қаралды 177 М.
My Favorite Code "Anti-Patterns" (Break These)
16:52
Conner Ardman
Рет қаралды 42 М.
Comparing C to machine language
10:02
Ben Eater
Рет қаралды 5 МЛН
Huffman Encoding Table First Try
31:00
TheVimeagen
Рет қаралды 15 М.
Rust's Alien Data Types 👽 Box, Rc, Arc
11:54
Code to the Moon
Рет қаралды 131 М.
15 crazy new JS framework features you don’t know yet
6:11
Fireship
Рет қаралды 244 М.
the TRUTH about this NEW Language (BETTER Than Rust and C++?)
7:37
Low Level Learning
Рет қаралды 338 М.
Huffman Encoding First Try
1:00:00
TheVimeagen
Рет қаралды 16 М.
WHY IS THE STACK SO FAST?
13:46
Core Dumped
Рет қаралды 130 М.
Ну Лилит))) прода в онк: завидные котики
00:51