[Types-sig] Re: Inferencing: A case study

Guido van Rossum guido@CNRI.Reston.VA.US
Tue, 14 Dec 1999 13:51:01 -0500


> Guido van Rossum wrote:
> > 
> > Here's a long and rambling example of what I think a type inferencer
> > could do -- without type declarations of any sort.  I wrote this down
> > while thinking about the type checker that I would like to see in
> > IDLE.
> 
> Okay, but let me ask this: if TOTAL Java-level type safety ONLY required
> type declarations for all "non-local" variables (including functions and
> instance variables) would that be acceptable to you?
> 
> Your inferencer heuristics are fine for an interactive GUI environment
> where failure is merely an inconvenience but if we are going to have a
> formally checkable notion of "this is statically type-safe" and "this is
> not" then I worry about the "non-local breakage" problem. Oops, did
> changing that variable to an "int" break your module way over there?
> 
> I spoke to the Journal of Functional Programmers at a conference
> recently. 

Is Journal some kind of military term, maybe between General and
Sergeant? :-)

> I asked him about why ML's type inferencer made the language
> so hard to use. He said: "oh, you should always put the type
> declarations in. The type inferencer is mostly just an educational
> tool." Of course that's not what the type inferencer was SUPPOSED to be,
> but I think that that's what it has become. "Global" type inferencing
> scares me and I think that it has the unintended consequence of making
> the static type checker (and thus the language) harder to understand.

I agree.  Typically, especially for libraries, there should be type
decls at the module boundaries to avoid endless "exercises for the
reader" as in my case study.  (Note that the case study actually
stipulates that the re module has a module declaration, and explains
why.)

--Guido van Rossum (home page: http://www.python.org/~guido/)