3 ms·
But there is still a function that panics. Java has solved memory safety. Now the task is to make sure that code that can panic will not compile
by benibela 7y ago
But there is still a function that panics.
Java has solved memory safety. Now the task is to make sure that code that can panic will not compile
- aw1621107 7y agoThe function that can panic still exists, but the ? operator itself won't invoke a panic. Sort of like how you can still get NullPointerExceptions in Kotlin using !!, but standard practice is to use a safer option. Exception/panic-free code is fairly straightforward; you just need to have APIs return Option<_>/Result<_>/other error code equivalents to indicate failure. The problem with that is that it introduces some amount of friction that will probably make some programmers unhappy. If you want to avoid returning Option<_>/Result<_>/other error code equivalents, you need some way to prove your inputs cannot trigger an invalid result, and that is a very difficult problem.