Hacker News new | ask | show | jobs
by kstenerud 51 days ago
My point is that you do the checking at the call site, and then use a static analysis tool or an AI to enforce checking the result right after calling parse_birthday.

Sure, Optional is more elegant, but the end result is the same: Now none of the other code needs to validate; it's already been verified valid at all points where a parse error could have occurred.

C may not be an easy language, but with the right tooling you can make code safer, and idioms like parse-dont-validate possible.