[OT] The Usual Arithmetic Confusions
Ola Fosheim Grøstad
ola.fosheim.grostad at gmail.com
Fri Feb 4 09:19:38 UTC 2022
On Friday, 4 February 2022 at 04:28:37 UTC, Walter Bright wrote:
> On 2/3/2022 8:25 AM, Paul Backus wrote:
>> The inconsistency is the problem here. Having integer types
>> behave differently depending on their width makes the language
>> harder to learn,
>
> It's not really that hard - it's about two or three sentences.
> As long as one understands 2s-complement arithmetic. If one
> doesn't understand 2s-complement, and assumes it works like 3rd
> grade arithmetic, I agree it can be baffling.
I don't think this is limited to learning. I don't think
programmers with decades of experience with C/C++ has a problem
understanding 2s-complement, but it is still creating annoyances
and friction.
Maybe it is time to acknowledge that most of the D user base use
the language for high level programming I would do the following:
1. make 64 bit signed integers with overflow checks the "default"
type across the board
2. provide a library type for range-constrained integers that use
intrinsic "assume" directives to provide the compiler with
information about constraints. This type would choose a storage
type that the constrained integer fits in.
3. add some clean syntax for disabling runtime checks where
higher speed is required.
D could become competitive with that and ARC + local GC.
D should try to improve on higher level programming as well as
the ability to transition from high level to system level in a
metamorphosis like evolution process.
More information about the Digitalmars-d
mailing list