How about adding rational fraction to Python?
Sat Mar 1 20:32:56 CET 2008
Lie <Lie.1296 at gmail.com> writes:
> I see, but the same arguments still holds true: the second line have
> an implicit side-effect of redefining x's type into Fractional type.
> If I were the designer of the language, I'd leave x's type as it is
> (as Num) and coerce x for current calculation only.
Num in Haskell is not a type, it is a class of types, i.e. if all you
know about x is that it is a Num, then its actual type is
indeterminate. Types get inferred, they do not get coerced or
"redefined". The compiler looks at expressions referring to x, to
deduce what x's type actually is. If it is not possible to satisfy
all constraints simultaneously, then the compiler reports an error.
More information about the Python-list