i love c but man a result type like in rust or zig error unions would be so much nicer
@Shreyassanthu77 Error unions are bad as a concept, you just want to return both the image as well as an error, so that you can still return useful results, and not force a branch on the API user.
@ryanjfleury hmm say I did the classic put pointer with an error return and set the image to zero or something then the user would have to handle the failure somewhere no? Like if they didn't check the error and come back to me with a zero image I would just have to return a new error??
@Shreyassanthu77 Nope, you can generally structure the API such that the user never checks anything (unless they want to).
@ryanjfleury so if loading fails all subsequent calls to my library just become no-ops?
@Shreyassanthu77 Yep
@Shreyassanthu77 Consider the API user, now. Their code becomes an always-correct, completely linear sequence of instructions: load_image_result_t load = load_image(...); image_t img = load.image; image_op1(img, ...); image_op2(img, ...); image_op3(img, ...); some_result_t r = image_op4(img);
@ryanjfleury @Shreyassanthu77 curious if you have any techniques for implementing this API other than checking for NULL in the implementation? like any cases where if a value is zero is automatically a no op?
@gdechichi @Shreyassanthu77 Depends a lot on the case. An empty array where the user is always bounds checking (e.g. by looping over it) will just naturally be skipped. A tree or graph structure can be returned either partially or with “nil nodes”, read-only nodes which you can safely read from but only
@ryanjfleury @gdechichi @Shreyassanthu77 Why are we ignoring the existence of errno like approaches? We can have a set of enums defined and an error field on the returned struct to determine which and what caused it
@ryanjfleury @gdechichi @Shreyassanthu77 Hey Ryan, IIRC, I think that in your blog post you mentioned having some per-thread system to output error information, so that you can reduce codepaths but still have error output. Are there any examples of this within the RAD Debugger code base that you’d suggest looking at?

