logoalt Hacker News

atherton94027today at 1:08 AM3 repliesview on HN

Genuinely curious, how would you handle cases where a value is unset without NULL? This is a legitimate case that happens a lot in eg data modeling


Replies

pdimitartoday at 1:55 AM

Sum types, of course.

show 2 replies
clnhlzmntoday at 1:48 AM

The way we do it in modern languages with things like std::optional and even that is not the best example.

show 1 reply
jibaltoday at 2:31 AM

They already said:

> use the type system to help us use special values safely

... but this is not the place to explain what a type system is or what sum types/maybe/optional/etc. are.