3 ms·
You're assuming that you can always make your declarations correctly express whether something can be null. Let's consider a real world example I hit: Every c
by LorenPechtel 2y ago
You're assuming that you can always make your declarations correctly express whether something can be null. Let's consider a real world example I hit: Every cell has a concept of it's neighbors. Now, the world isn't infinite, some of those pointers are null. But there's a boundary layer of edge-of-the-world cells to keep you from going too far.
Thus, in the real world null can never occur--but there are a gazillion places where it would have to test for a null that should never happen. Or simply Assert in the routine itself.
- gwbas1c 2y ago> You're assuming I'm not. It's pretty clear that you don't know how null safe Swift, C#, and Rust work. IE: Rust has the option type for when a value can be null, and the compiler forces you to do an "empty" check. Otherwise, null, does not exist in the language. Swift and C# are more metadata based. You indicate if a value supports null or not. The compiler will give you a warning, or error depending on configuration, if you try to assign null to a value that does not expect it. All three languages have a concept of values that can be null, (or empty in Rust if you want to argue semantics,) so your type system tells you when a value can be null, or when it is expected to not be null. In all three languages, the compiler can force you to make assignments before you use an object.
- gwbas1c 2y agoIn Rust, you use https://doc.rust-lang.org/std/option/ https://doc.rust-lang.org/std/option/ when a value could be "null", otherwise a value is never null. C# has https://learn.microsoft.com/en-us/dotnet/csharp/nullable-references https://learn.microsoft.com/en-us/dotnet/csharp/nullable-ref...