On 12/2/05, Anthony Borla <[EMAIL PROTECTED]> wrote: > I *do* miss implict type conversion behaviour [e.g. C 'type promotions'], > and have been bitten [numerous times] by simple code such as: > > <float> / <int> >
The thing about type conversions is that they can be lossy (i.e. lose information), and worse, they're silently lossy. I sometimes wonder whether the reason static typing is so popular in C and its descendants is because C is so quiet about type errors; it's *hard* to detect a stale pointer at runtime, and it's *hard* to detect that you're losing precision when you call a hypothetical abs(int) with -2.44 and come out with 2, so if someone is likely to make that error you provide an overloaded abs(double). Perhaps one reason Mozart can get away with dynamic typing is because it will shout at you when you try to do arithmetic on Float |X| Int, so you don't get coerced Floats slowly infecting your data structures as they subvert Ints with their coercive propaganda, every time they're paired with one for a binary operation. This wouldn't matter so much if Floats didn't have such very different properties from Ints, unlike say fixed-point numbers... it makes it very difficult to reason about the semantics of your calculation. I am more and more coming to appreciate Mozart's strict aversion to arithmetic type coercion. Max Wilson -- Be pretty if you are, Be witty if you can, But be cheerful if it kills you. _________________________________________________________________________________ mozart-users mailing list [email protected] http://www.mozart-oz.org/mailman/listinfo/mozart-users
