Walter Bright:

>All the various solutions tried over the decades have failed to catch on. This 
>leads me to believe that either these obvious solutions do not work, or they 
>cause more problems than they fix.<

I was not asking to turn D into Ada, but for a tidier number system. The things 
I was asking are more or less all implemented in the C# language, that is a 
successful (and pleasant to use) language.
If you use C# for few days for real, you can get some practice in such things 
too. If you don't like to install dotnet, you can install mono.


>That's a valid argument if you're writing a spreadsheet program. But 
>programmers should be amiliar with computers, and most definitely should be 
>familiar with 2's complement arithmetic. Similarly, if you do much with 
>floating point, you should be familiar with "What Every Computer Scientist 
>Should Know About Floating-Point Arithmetic"<

I agree that a programmer of a system language has to know how fixnums work and 
has to know some of the basic things about floating point numbers (in truth I 
don't think 99.9% of programmers know everything written in that article about 
FP, it's a long and complex paper).

But the number of integral-related bugs in C/C++ programs show that even expert 
programmers (that surely know what C fixnums are) when they program sometimes 
"forget" the finite nature of numbers, probably because a human can keep in 
mind only a very limited number of things at the same time (and most of those 
things are other details of the algorithm/problem to implement/solve). So a 
good language doesn't force the programmer to remember the low level details 
all the time, it allows the programmer to use and remember those low level 
details when they are needed, or in high-performance situations.

If you pull the trigger of a revolver it will shoot (if it's loaded, etc), but 
even expert gun users think a the safety is handy, because it helps you to not 
keep attention all the time to avoid pulling the trigger. Knowing the nature of 
binary numbers is necessary, and it's bad to hide their nature in a system 
language, but in most parts of a program, even written in a system language, I 
want a safety. There are situations where you want a modulo arithmetic 
behaviour, but in most situations that's not what you desire (and the number of 
such bugs in programs shows that the brain of the programmers slip back in the 
'school arithmetic mode' often).

(Later I have also said that I'd like a way to help the compiler tell apart the 
two ways of using numbers, the modulo arithmetic from the finite+overflow one).

Bye,
bearophile

Reply via email to