On Mon, Jul 30, 2001 at 05:58:22AM +0900, Paul Prescod wrote:
> Anyhow, even if Python or Ruby never adopts rationals, I tend to think
> that the substitutability principle is more important than the principle
> that "any operation on two exact numbers should not result in inexact
> number, unless explicitly specified." I would say if you strongly
> believe that then the consistent thing to do is disallow all uses of
> exact integers in place of floats. You could just as easily extend the
> principle to say: "no operation involving an exact number should result
> in an inexact number." Then people would be trained that floats and
> integers are deeply different and distinct and they wouldn't accidently
> pass integers to functions expecting floats.

If you write a function, which depends on 1/2 being 0.5, why don't you just
write a.to_f / b.to_f?

This way, your function will work in every case, and even if the behaviour
is changed, the code will not break.

It kind of the same, as (i guess) it's good style to write .to_s after a
variable which you expect to be a string, but don't depend on
it apart from being able write it to some output.

greetings, Florian Pflug