▲ | integricho 4 days ago | |||||||||||||||||||||||||||||||
Though is there a significant difference in which is more bad between running into undefined behavior and panic? | ||||||||||||||||||||||||||||||||
▲ | kstenerud 4 days ago | parent | next [-] | |||||||||||||||||||||||||||||||
In C, sure. C is a dangerous language of its time. But these contracts don't make things better. Now you're removing control from the user. So now if an allocation fails, you crash. No way to recover from it. No getting an error signal back (NULL) so that you can say "OK, I need to clear up some memory and then try again". (Note that I'm not saying that inline error signaling such as NULL is good design - it's not). Nope. No error handling. No recovery. You crash. And ain't nothing you can do about it. That's just bad design on top of the existing bad design. Things that crash your app are bad. No need to add even more. | ||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||
▲ | ost-ing 4 days ago | parent | prev [-] | |||||||||||||||||||||||||||||||
Exactly, panicking is a safer way to handle the situation rather than memory access violations | ||||||||||||||||||||||||||||||||
|