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

Everything mentioned in this post relates to API level, for code that you control. You can pick your favorite type for optional values with the possibility of an error.

Exceptions, on the other hand, can come from code you don't control. Some DLL that you call into doesn't care if you like Option<T> better, it's still going to throw an exception. It could be designed to "throw" using the C++ exception syntax, or it could simply be dereferncing a null pointer or dividing by zero, causing an exception.

So then the issue becomes support for catching the exceptions caused by code outside of your control.

One option is to do nothing and just let the program die.

The other option is to catch the exception, automatically save the user's work, then restart the program.



I see, but isn't exceptions implementation specific? How does language X knows how some random binary/DLL is going to throw an exception? What kind of object does it throw? What does it look like? How big is it? How many nested exceptions are there?


Windows has an ABI for exceptions, I don't know about Linux.




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

Search: