Timeline for Why F#, Rust and others use Option type instead of nullable types like C# 8 or TypeScript?
Current License: CC BY-SA 4.0
5 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jun 3, 2020 at 4:09 | comment | added | Andy Dent | Thanks for highlighting the 3rd state. It's one of the things Swift does fairly well and why I'm so happy having moved to it from C++. It's also why purely adding your own optional implementations as a library doesn't work nearly as well. | |
May 29, 2020 at 22:18 | comment | added | Beefster | I see what you mean now. Upvoted. It's a little confusing the way you phrased it. Basically state 2 is schrodinger's nullable, and it can be handled reasonably with static analysis. | |
May 29, 2020 at 22:02 | comment | added | Karl Bielefeldt |
If you ever do a if var == null , then you are in the second state transitioning to one of the other two. If you never do a null check, you don't need a nullable reference.
|
|
May 29, 2020 at 21:54 | comment | added | Beefster | "Nullable types need 3 states in order to be safe and useful" - I rarely need a third state. Distinction between 'deliberately null' and 'uninitialized' is only needed regularly by the most eccentric javascript programmers. | |
May 28, 2020 at 13:34 | history | answered | Karl Bielefeldt | CC BY-SA 4.0 |