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

Integer arithmetic traps on overflow -- and that includes the often forgotten "divide by INT_MIN" case:

https://github.com/austral/austral/blob/01a6327815d1f9cc1097...

You have to use a different set of operators to get modular arithmetic semantics. So, the choice is not a flag you flip at build time, but a choice of operators.



Thanks for your answer.

>You have to use a different set of operators to get modular arithmetic semantics. So, the choice is not a flag you flip at build time, but a choice of operators.

Like Zig I think.

As for 'panic at overflow' I think that Erlang/Elixir is the same so there are probably a lot of 'design patterns'/libraries to get inspiration from there.

One note, your language allow usage of 'named parameters' as in "return File(handle => ptr);" so this means that the name of the parameter is part of the API and must be chosen carefully.. ptr isn't a very good name, handle would be a better name, but then of course you have "return File(handle => handle);" which is a classic problem of named parameters..




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

Search: