disabling unary "-" for unsigned types
Walter Bright
newshound1 at digitalmars.com
Tue Feb 16 02:27:36 PST 2010
Lutger wrote:
> It's a valid viewpoint, but it is a 'should'. I believe many programmers
> have only passing familiarity if at all with the semantics of unsigned types
> and floating point operations. At least when coding, they don't have these
> semantics in mind. Why do you think Java doesn't have unsigned types?
Naive programmers have trouble with Java floating point as well:
http://www.eecs.berkeley.edu/~wkahan/JAVAhurt.pdf
There's just no getting around it. Should Java just remove floating
point types as well?
Heck, I knew a degree'd mechanical engineer who could not understand why
his calculator kept giving him answers off by a factor of 2 (he refused
to understand roundoff error, no matter how many times I tried to
explain it to him - he believed that calculators had mathematically
perfect arithmetic). We could ban calculators, but misuse of slide rules
is far worse.
> However D does seem to target C#/Java and even python programmers. It is
> often suggested D's 'system programming' features are not actually *needed*
> and it offers enough high-level and safe features for programmers not
> comfortable with C / C++ to program effectively. This reasoning does not
> hold for unsigned integers and floating point vagaries.
Pointers are far more troublesome than negating an unsigned.
In my experience with beginning programming courses, the very first
thing they explained was 2's complement arithmetic. I do not think it
unreasonable at all that someone using a powerful systems programming
language ought to understand it.
More information about the Digitalmars-d
mailing list