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

From: John Clements (clements at brinckerhoff.org)
Date: Thu Mar 4 16:50:59 EST 2010

On Mar 4, 2010, at 1:41 PM, Raoul Duke wrote:

> On Thu, Mar 4, 2010 at 1:11 PM, John Clements <clements at brinckerhoff.org> wrote:
>> That is: the type checker couldn't figure out what kind of thing (List()) was, so it conservatively decided that it was List[Nothing].  Then, you get an error at some arbitrarily distant location. You can solve this by adding a type annotation to List(). Bflegg.
> 
> 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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2484 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20100304/d16304f9/attachment.p7s>

Posted on the users mailing list.