[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dynamic vs. static typing




On Nov 26, 2003, at 12:16 PM, Anton van Straaten wrote:
>
> Perhaps this would be a good time for Shriram to expand on an earlier
> comment he made (on Tue 11/18/2003 at 4:58 PM):
>
>> type systems that work by inference, rather than annotation
>> checking, often do not explicitly "check".  This phenomenon
>> is why they sometimes provide incomprehensible type errors.
>> (I can explain this in a bit more detail if anyone cares.)
>
> I understand the general principle that the more abstract a piece of 
> code
> is, the harder it becomes to produce errors (and other information) 
> that are
> meaningful to the domain to which the code is being applied.  Is there
> anything more specific at work in the type inferencing case that makes 
> more
> meaningful errors more difficult (or impossible)?

Only the obvious one; rather than checking a type that you (the 
programmer)
have written, the type-checker is checking types that it has inferred 
from
(possibly distant) "clues" that you have provided.  I'll venture to 
guess that anyone
who's written ML code has both blessed its type system for catching 
bugs and
cursed profusely while trying to figure out WHY the type system thinks 
that
'x' is supposed to be an int when it's so OBVIOUSLY of type 
'int->string'


> With highly abstract code, it's often possible to do a better job of 
> error
> reporting by providing additional information when specializing the 
> code.  I
> suppose one type system equivalent would simply be to provide explicit
> annotations, thus possibly losing both polymorphism and inferencing.  
> Are
> there better options?

I don't see why explicit annotations should cost you polymorphism.

john