News for hackers. Stuff that matters.
Re:Why is Zig so Cool? by qouteall on Friday November 07, 2025 @10:19PM (#45853822)
I know that Zig doesn't allow attaching data to error for valid reasons. If error data contains interior pointer then it can easily cause memory safety problem. Zig doesn't have a borrow cheker or ownership system to prevent that.

https://github.com/ziglang/zig/issues/2647#issuecomment-2670...

Re:Why is Zig so Cool? by metaltyphoon on Friday November 07, 2025 @10:23PM (#45853845)
> I know that Zig doesn't allow attaching data to error for good reasons. If error data contains interior pointer then it causes memory safety problem

IMO this is not a good reason at all.

Re:Why is Zig so Cool? by qouteall on Friday November 07, 2025 @10:29PM (#45853877)
Changed to "valid reasons"
Re:Why is Zig so Cool? by jibal on Saturday November 08, 2025 @12:02AM (#45854284)
The problem of dangling pointers is not unique to error data.
Re:Why is Zig so Cool? by 59nadir on Saturday November 08, 2025 @05:34AM (#45855710)
If you wanted to have a parameter that gets filled in when there is an error, this exact issue will remain, it's completely unrelated to which language construct you use to capture errors and has more to do with having a good idea of how your errors are allocated, if they require allocation. I don't think the commenter in the GitHub issue thought this through at all, and probably didn't expect to have it be held up as some example of why you can't return tagged unions (because it's not an example of that, not even remotely).