-
Notifications
You must be signed in to change notification settings - Fork 64
Unsigned types don't have "neg" #310
Comments
I would recommend keeping unsigned |
Let's get rid of neg from unsigned types. It was a typo on my part to include them; I don't think it was anyone's intention. |
Currently, the signed and unsigned integer types support the same set of operations. This is a desirable property of a compilation target. Would it make sense to remove |
I did a quick survey of programming languages that provide fixed-size unsigned integer types:
|
ARM Neon has a hardware negate instruction for the 64-bit types |
This is pretty much a continuation of #191: SIMD really expresses operations, some of which are signed / unsigned and some of which are sign-agnostic. The type system is expressed in terms of signed / unsigned, and it sometimes maps weirdly. IMO in this case neg should either:
|
OK, I'm convinced, let's keep neg for unsigned and fix the polyfill and tests. |
I'm not fixing it. I'm making sure it errors always. We don't have unary negation. What we have is unary not, so we do Ada's modular types are like Rust's So if your types are wrapping (unsigned::MAX + 1 == unsigned::MIN) then it's probably correct to support them. If that's not happening, this might be very suprising in some situations that unary negation works. |
Seems the consensus here is to have neg for both sign/unsigned ? Polyfill/tests still need to be fixed. |
Yes, I believe that was the consensus on the last call where we discussed it. |
The spec says that all integral types (signed and unsigned) should implement neg, although the polyfill doesn't have them. Is it that the polyfill is missing them, or is it that the spec shouldn't define them for unsigned types?
As noted by Jakob Olesen in https://bugzilla.mozilla.org/show_bug.cgi?id=1233111#c17 , they can be implemented with modulo arithmetic.
The text was updated successfully, but these errors were encountered: