On Mar 1, 11:23 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
(snip)
> But the type of `x` must be specialized somehow.  `x` doesn't start as
> `Int` or `Integer` but the very generic and AFAIK abstract type class `Num`.
>
> After seeing the second line the compiler finds an implementation for `+`
> and the type class `Fractional` for both operands and now thinks `x` must
> be a `Fractional`, a subclass of `Num`.
>
> Then comes the third line with `length` returning an `Int` and the
> `Fractional` `x` but there is no implementation for a `+` function on
> those types.

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.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to