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

From: Prabhakar Ragde (plragde at uwaterloo.ca)
Date: Thu Mar 4 17:37:07 EST 2010

John Clements wrote:

> 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.

The Odersky et al. book "Programming In Scala" has a very similar 
example in section 16.9, and explains that this is due to Scala's 
"local, flow-based typing algorithm" as opposed to the more general 
Hindley-Milner-style algorithms. It does not, however, give an example 
to demonstrate that the choice of "Nothing" is the right choice in some 
situations. --PR

Posted on the users mailing list.