←back to thread

157 points matt_d | 1 comments | | HN request time: 0.198s | source
Show context
kubb ◴[] No.45136229[source]
For people using OCaml, there’s one thing that kinda discourages me in it, that is exceptions as part of the API in the standard library.

Because exceptions aren’t checked, this effectively means that a language designed for type safety has as much type safety as python, because it’s very easy to forget handling something, and get runtime errors.

How do you deal with this day to day? I assume it’s impossible to just believe that all the code you pull in doesn’t use exceptions?

replies(4): >>45136795 #>>45137250 #>>45137299 #>>45142057 #
1. yodsanklai ◴[] No.45136795[source]
> as much type safety as python

That's an exaggeration.

You can use error types / monads like you would do in Rust/Haskell. When you use the Core standard library, you can use function who don't throw exceptions. Those who do use specific name conventions (foobar_exn).