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

From: John Clements (clements at brinckerhoff.org)
Date: Thu Mar 4 17:05:51 EST 2010

On Mar 4, 2010, at 1:56 PM, Carl Eastlund wrote:

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

There's a difference between assigning a fresh type variable and choosing a base type at random. This is like "solving" x+4=8 by saying "let's suppose that x is 3. Nope, this equation doesn't check."
-------------- 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/d58a4ee3/attachment.p7s>

Posted on the users mailing list.