3 ms·
> One more idea I didn't see is to mark the variable as "invalid". That's what NaN is.
by ori_b 12y ago
> One more idea I didn't see is to mark the variable as "invalid".
That's what NaN is.
- aromogato 12y agoNot quite, marking a variable as invalid in this context is essentially a job for the type system. For example, in C, you can have a void* which can be null. This can lead to seg faults, and NaN has the same pitfall. Instead, with the Maybe idea above, the type system explicitly makes you handle the NaN case since the type is a discriminated union. This is like `int?` in C#.