(no title)
PhantomGremlin | 4 years ago
Too bad programmer laziness won and most current hardware doesn't support this.
As a teenager I remember getting hit by this all the time in assembly language programming for the IBM S/360. (FORTRAN turned it off).
S0C8 Fixed-point overflow exception
When you're a kid you just do things quickly. This was the machine's way of slapping you upside your head and saying: "are you sure about that?"
masklinn|4 years ago
There were discussions around this a few years back when Regher brought up the subject, and one of the issues commonly brought up is if you want to handle (or force handling of) overflow, traps are pretty shit, because it means you have to update the trap handler before each instruction which can overflow, because a global interrupt handler won't help you as it will just be a slower overflow flag (at which point you might as well just use an overflow flag). Traps are fine if you can set up a single trap handler then go through the entire program, but that's not how high-level languages deal with these issues.
32b x86 had INTO, and compilers didn't bother using it.
Findecanor|4 years ago
BTW. The Mill architecture handles exceptions from integer code like floating point NaN: setting a meta-data flag called NaR - Not a Result. It gets carried through calculations just like NaNs do: setting every result to NaR if used as an operand... Up until it gets used as operand to an actual trapping instruction, such as a store. And of course you could also test for NaR instead of trapping.
monocasa|4 years ago
And in x86 land there's the into instruction, interrupt if overflow bit set, so you're left with the same options.
spc476|4 years ago
flohofwoe|4 years ago
The question is rather: was it really a good idea to bake 'signedness' into the type system? ;)
pornel|4 years ago
masklinn|4 years ago
That’s an extremely disingenuous line of reasoning, the situations where it’s a feature is a microscopic fraction of total code: most code is neither interested in nor built to handle modular arithmetics, and most of the code which is interested in modular arithmetics needs custom modulos (e.g. hashmaps), in which case register-size-modulo is useless.
That leaves a few cryptographic routines built specifically to leverage hardware modular arithmetics, which could trivially be opted in, because the developers of those specific routines know very well what they want.
> signed vs unsigned are just different views on the same bag of bits […] The question is rather: was it really a good idea to bake 'signedness' into the type system? ;)
The entire point of a type system is to interpret bytes in different ways, so that’s no different from asking whether it’s really a good idea to have a type system.
As to your final question, Java removed signedness from the type system (by making everything signed). It’s a pain in the ass.
zozbot234|4 years ago
zozbot234|4 years ago
addaon|4 years ago
laumars|4 years ago
I don’t think this is a age problem. Plenty of adults are lazy and plenty of kids aren’t.