Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> To me, panic is the most laziest and worst ways to put in a specification.

This why the "existing programs don't have specs!" Hand-ringing is entirely premature. Just about every code base today has error modes the authors think won't happen.

All you have to do is start proving they won't happen. And if you do this, you will begin a long journey that ends up with a formal spec for, at least, a good part of your program.

Proving the panics are dead code is a Socratic method, between you and the proof assistant / type checker, for figuring out what your program is and what you want it to be :).





Orrrr just use an API that returns Option<T>, then bubble it up or manually panic if that's what you want?



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: