This seems like what could be a common cause of bugs
bearophile
bearophileHUGS at lycos.com
Mon Aug 15 10:22:26 PDT 2011
Marco Leise:
> That's why Pascal uses another set of operators for integer divisions,
> namely 'div' and 'mod', so you can never get into that situation. The
> above code would have worked and in case step was an integer, the compiler
> would have complained about not using 'div'. I doubt that we will see
> these in D - at the end of the day code that is both valid C and valid D
> must do the same thing, but I never had problems with 'div' and 'mod' and
> it seems like a good solution.
On this I like the Pascal design better. I think in D2 you can't change how division works. Python2 has done this during its evolution to Python3, but D has to keep some compatibility with C.
But adding an integer division operator to D and later discouraging (with a warning too) the usage of the normal division operator for integer numbers is a possibility (later if you want to port C code to D you see many deprecation integer division warnings. A hypothetical c2d tool based on DMD source is later able to fix your C code ported to D).
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list