Test cases and static typing

Pascal Costanza costanza at web.de
Fri Oct 24 18:17:22 EDT 2003


Dirk Thierbach wrote:
> Pascal Costanza <costanza at web.de> wrote:
> 
> 
>>As long as I am writing only tests, I don't care. When I am in the mood 
>>of writing tests, I want to write as many tests as possible, without 
>>having to think about whether my code is acceptable for the static type 
>>checker or not.
> 
> 
> Then just do it. Write as many tests as you care; when you're ready,
> compile them and run the type checker.
> 
> Where's the problem? One thing that is certainly missing for Haskell or
> OCaml is a good IDE that supports as many styles of programming
> as possible, but even with the primitive command line versions at the
> moment you can do what you want in this case.
> 
> And anyway, this would be a question of the IDE, not of static typing.

A flexible and useful IDE must treat static type checking as a separate 
tool. It needs to be able to do useful things with code that isn't 
correct yet. Modern IDES even give you parameter lists, etc., when the 
code isn't actually completely parsable.

And that's all I wanted from the very beginning - static typing as an 
additional tool, not as one that I don't have any other choice than use 
by default.

>>>>The type system might test too many cases.
> 
> 
>>>I have never experienced that, because every expression that is valid
>>>code will have a proper type.
> 
> 
>>>Can you think of an example (not in C++ or Java etc.) where the type
>>>system may check too many cases?
> 
> 
>>Here is one:
>>
>>(defun f (x)
>>  (unless (< x 200)
>>    (cerror "Type another number"
>>            "You have typed a wrong number")
>>    (f (read)))
>>  (* x 2))
> 
> 
>>Look up 
>>http://www.lispworks.com/reference/HyperSpec/Body/f_cerror.htm#cerror 
>>before complaining.
> 
> Done. But I still miss the point. OTOH, Lisp certainly doesn't check
> types, so I don't see how a Lisp program can be an example of the
> type system checking too many cases. OTOH, this example is tied to
> a specific Lisp debugger feature. I think it would be better to give
> an example in a statically typed language.

No, it's not better to give an example in a different language. The 
whole point of my argument is that the code above cannot be statically 
type-checked. And the feature presented is extremely helpful, even in 
end user applications.

> I could probably rewrite the code with an approximation to cerror
> (with the restriction that non-local control structures don't 
> translate one to one), but even then I don't see why the type system
> would test too many cases for this example.

I don't want an "approximation of cerror". I want cerror!



Pascal

-- 
Pascal Costanza               University of Bonn
mailto:costanza at web.de        Institute of Computer Science III
http://www.pascalcostanza.de  Römerstr. 164, D-53117 Bonn (Germany)





More information about the Python-list mailing list