[Types-sig] Type Inference I

Martijn Faassen faassen@vet.uu.nl
Sat, 18 Dec 1999 23:54:12 +0100


Tim Peters wrote:
> Indeed, I think it should forget inferencing *entirely* at the start, even
> for cases like

> def unity() -> Int:
>     a = 1   # compile-time error in type-check mode -- a not declared
>     return a

To use my famous phrase again: I agree.

The counter argument I got to this before is that inferencing takes place
anyway in the case of expressions:

def foo(a, b):
    # Martijn's evil verbose format in yet another form
    decl:
        a = Int
        b = Int
        return Int
    return a + b

'a + b' would need inferencing to figure out what the type is of the complete
expression. I think that this argument overlooks that this kind of evaluation
is a lot more easy than a back-tracking kind of inferencing. 
 
> Inferencing (ya, ya -- *useful* inferencing) is harder than mere checking
> (indeed, checking is easy enough to write in K&R C <wink>).

Though checking could be seen as a kind of inferencing, right? Or are
people confusing the issues? Initially I didn't consider the expression
evaluation stuff as inferencing either, but there's a good argument to
consider it so, not?

Regards,

Martijn