|
|
|
|
|
by ReleaseCandidat
950 days ago
|
|
I don't like Exceptions in OCaml (or Haskell or C++ or JS/TS) either. But they aren't unsafe, except for bugs in the compiler/runtime (in OCaml, in C++ there are of course some footguns ;).
Of course they add "bottom" to any function where an Exceptions can occur (and other things, see for example
https://markkarpov.com/tutorial/Exceptions) but for stuff like `0/0` there are 3 possibilities: use something like `Maybe` for the result - clumsy. return (for example) 0, which is what most theorem provers (like Coq or Lean and dependently typed languages like Idris) do, that need their functions to be total or throw an exception. (C's solution of declari g it undefined behavior is missing). Now, with OCaml's effect systém, there also is no need to use exceptions for control flow - which you should have never done anyway. |
|