News for hackers. Stuff that matters.
Re:Erg: a statically typed language that is Python compatible by elcritch on Saturday August 13, 2022 @10:42PM (#32455859)
Wow, I thought Rust's integers would let you handle integer overflows.. Apparently thats not the case and overflows are only checked in debug builds and then they just panic. Huh.

After programming in Nim (and Python back in the day), I've become used to being able to detect integer overflows as a normal exception. At least for signed ints, since not all CPU support efficient overflow detection on unsigned ints. Its handy to to let uints wrap as sometimes thats what you want. I figured all new languages would do similar things.

Re:Erg: a statically typed language that is Python compatible by bobbylarrybobby on Sunday August 14, 2022 @12:52AM (#32456453)
Rust has a variety of checked methods -- `checked_add` etc -- that allow for fallible int operations. And there are corresponding `wrapping_` versions that indicate wrapping is the correct behavior (and shouldn't panic in debug builds).