Static typing

Pascal Costanza costanza at web.de
Thu Oct 23 07:12:17 EDT 2003


Dirk Thierbach wrote:
> Pascal Costanza <costanza at web.de> wrote:
> 
>>You need some testing discipline, which is supported well by unit 
>>testing frameworks.
> 
> IMHO it helps to think about static typing as a special kind of unit
> tests. Like unit tests, they verify that for some input values, the
> function in question will produce the correct output values. Unlike
> unit tests, they do this for a class of values, instead of testing
> statistically by example. And unlike unit tests, they are pervasive:
> Every execution path will be automatically tested; you don't have
> to invest brain power to make sure you don't forget one.

This is clear.

> Type inference will automatically write unit tests for you (besides
> other uses like hinting that a routine may be more general than you
> thought). But since the computer is not very smart, they will test
> only more or less trivial things. But that's still good, because then
> you don't have to write the trivial unit tests, and only have to care
> about the non-trivial ones.

Unless the static type system takes away the expressive power that I need.

> Type annotations are an assertion language that you use to write down
> that kind of unit tests. 

Yep.

> Of course you can replace the benefits of static typing by enough unit
> tests. But they are different verification tools: For some kind of
> problems, one is better, for other kinds, the other. There's no reason
> not to use both.

I have given reasons when not to use a static type system in this 
thread. Please take a look at the Smalltalk MOP or the CLOS MOP and tell 
me what a static type system should look like for these languages!


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