Maximilian Wilson wrote: > On 12/2/05, Maximilian Wilson <[EMAIL PROTECTED]> wrote: > >>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. > > Come to think of it, it strikes me that C-style type promotion (an int > is a float) is a bad idea for the same reason that "a square 'IS A' > rectangle" is now widely considered to be a fallacy. A square has the > same *data* as a rectangle, but it has extra constraints, so the > Liskov substitution principle doesn't hold if squares are mutable.
But ints and floats are not mutable, so the reason is not the same. I agree that int should not be considered a subtype of float, though. Floating point arithmetic gives numerically different results than integer arithmetic (since it may lose precision), and this is sufficient reason by itself not to consider int a subtype of float. In O'Caml, different operators are used to reflect this, e.g. + for integer addition, +. for floating point addition. -- David Hopwood <[EMAIL PROTECTED]> _________________________________________________________________________________ mozart-users mailing list [email protected] http://www.mozart-oz.org/mailman/listinfo/mozart-users
