3 ms·
What's Austral story for integer overflow? Division errors are explained but not the other errors, I guess that they abort too?
by renox 4y ago
What's Austral story for integer overflow?
Division errors are explained but not the other errors, I guess that they abort too?
- zetalyrae 4y agoInteger arithmetic traps on overflow -- and that includes the often forgotten "divide by INT_MIN" case: https://github.com/austral/austral/blob/01a6327815d1f9cc10975b75b2b24f42428ac6b2/lib/builtin/Pervasive.aum#L129 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.
- renox 4y agoThanks 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..