Hacker News new | comments | show | ask | jobs | submit login

In case you're wondering, Elm has a strict "no runtime errors" rule, but avoids this by not having integers.

Another interesting example is array access. What should a[len(a)+1] be if your language doesn't have runtime errors?

Elm returns a Maybe type. However, this would be very awkward if you're actually doing a lot of calculations using arrays.

[Edit: Pony is different.]

Pony does have exceptions, and indexing an array does raise if the index is out of bound. It doen't have runtime errors because all exception must be handled somewhere in the call stack, the sooner, the better.

Because of this rule, defining / as a partial function forces the user to fence every single division in a try clause.

Using boxed integer as Elm does is not an option as Pony targets high-speed computing, not browser rendering. Different fields, different trade-offs.

Defensive users can well define `div(I32, I32): I32?` that throws an error and use it instead of `/`.

As repeated in this thread, 1/0 is undefined because nonsensical. So, it's OK to have any sane, consistent and well documented behaviour. At least with Pony, the user can choose speed and convenience when they're sure there is no possible 0 at this place. Well, TBH, I think it's always the case. Because there is no such thing as a division by zero, you're algorithm is simply wrong and unsound if it ends up dividing by 0, and that's where this case differs from integer overflow

Note: in Pony literature, "partial" means "can throw an error". "partial" as in "doesn't apply to the whole domain of the arguments types"

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