Skip to main content
10 events
when toggle format what by license comment
Jul 6, 2023 at 14:11 vote accept BoppreH
Jul 1, 2023 at 22:16 answer added Michael Homer timeline score: 4
Jul 1, 2023 at 21:47 comment added user If your language only has floats and no separate integer types, then you wouldn't need to worry about a / 0 at all thanks to +/-Infinity and NaN.
Jul 1, 2023 at 21:26 comment added Bbrk24 I’ll note that Swift, the language that was fine with adding jo ud2 after every add and imul, said that returning an optional on array access would make it unacceptably slow.
Jul 1, 2023 at 21:23 comment added user @BoppreH I'd assume it's simply because it'd be too much of a pain, given how often you need to use / and [] in Rust. Rust is verbose, but requiring ? for division and array access would possibly make it unbearably verbose and turn off programmers from using it. That said, I'm just guessing, I'm not even a Rust programmer. Elm returns a Maybe on array accesses, but that's the only mainstream language I know of that does that
Jul 1, 2023 at 21:14 comment added BoppreH @user I think that's a perfectly ok answer, especially because Rust itself opted to not have division and array access return Results. If you find out why, that's an A+ answer.
Jul 1, 2023 at 21:14 comment added mousetail Even rust doesn't let you use ? for division by zero or array indexing, they just panic
Jul 1, 2023 at 21:10 comment added user Too minor to be an answer, but these operations could return an Option or Result, and your language could have some sugar for "unwrapping" those (e.g. a safe navigation operator such as ?., or ? like in Rust).
Jul 1, 2023 at 21:00 history edited BoppreH CC BY-SA 4.0
added 51 characters in body; added 119 characters in body
Jul 1, 2023 at 20:50 history asked BoppreH CC BY-SA 4.0