[plt-scheme] The problem with Scala (OT, sorry)

From: Carl Eastlund (carl.eastlund at gmail.com)
Date: Thu Mar 4 16:56:36 EST 2010

On Thu, Mar 4, 2010 at 4:50 PM, John Clements <clements at brinckerhoff.org> wrote:
>> it is my rough anecdotal hear-say understanding that this happens in
>> other languages that have type inference. iiuc, the wisdom for
>> programming in ocaml is to actually put in type annotations anyway so
>> that errors show up closer to the real human error, rather than miles
>> away due to a type checker that manged to keep on trucking.
> No, I believe you're mistaken. It's possible (probable?) that type systems for (e.g.) Haskell
> and OCaml have funny corner cases, and they can certainly also produce bad error
> messages, but to the best of my knowledge they don't ever "guess" a type and then keep
> going. So, for instance, I believe it's the case at least for the core of the language that
> deleting all of the type annotations should not affect the semantics of the program.  Then
> again, Java's types are all tangled up with its semantics, so I suppose I shouldn't be
> surprised. In this case, though, it would have seemed a better choice to say "please give
> me a type for this empty list" than to guess at the List[Nothing] type.
> John

John... "guess a type and then keep going" is all that inference
algorithms ever do.  It's not a corner case for Haskell and OCaml,
it's the default.  Why else do you think the programs work, as you
say, with all the annotations removed?


Posted on the users mailing list.