Detecting inadvertent use of integer division
bearophile
bearophileHUGS at lycos.com
Mon Dec 14 05:17:20 PST 2009
Don:
> > In Pascal too (and OCaML, but the situation is different) they are separated. I think here having two operators is better,
>
> Why?
You are intelligent and expert so you must know my answer, so I fear yours is a trick question :-)
Two operators allow to reduce the need for casts (and rounding/truncation), and are more explicit, allowing the code to express its meaning better to people that come after the original programmer.
You can put them in the middle of a long expression, so you know what it's happening in the middle of it. This is useful for programming newbies too. I know there's a C translation of every usage of those two operators, but this is beside the point: even if the Laws of C language are sometimes explicit, sometimes they are not so natural and easy to remember, because normal people are not computers.
Not every part of the C language is designed perfectly, there's space for improvements.
Bye,
bearophile
More information about the Digitalmars-d
mailing list