Test cases and static typing

Dirk Thierbach dthierbach at gmx.de
Fri Oct 24 12:53:31 EDT 2003


Pascal Costanza <costanza at web.de> wrote:
> Dirk Thierbach wrote:

> OK, I have got it. No, that's not what I want. What I want is:
> 
> testxyz obj = (concretemethod obj == 42)
> 
> Does the code compile as long as concretemethod doesn't exist?

No. Does your test pass as long as conretemthod doesn't exist? It doesn't,
for the same reason.

>> It's the same with compile-time type errors. The only difference is
>> that they happen at compile-time, not at test-suite run-time, but the
>> necessary reaction is the same: Fix your code so that all tests (or
>> the compiler-generated type "tests") pass. Then continue with the next
>> step. 

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

> I don't compile my programs. Not as a distinct conscious step during 
> development. I write pieces of code and execute them immediately. 

I know. I sometimes do the same with Haskell: I use ghc in interactive
mode, write a piece of code and execute it immediately (which means it
gets compiled and type checked). When it works, I paste it into
the file. If there was a better IDE, I wouldn't have to do that,
but even in this primitive way it works quite well.

> It's much faster to run the code than to explicitly compile and/or
> run a type checker.

Unless your modules get very large, or you're in the middle of some
big refactoring, compiling or running the type checker is quite fast.

> This is a completely different style of developing code.

I have known this style of developing code for quite some time :-)

- Dirk





More information about the Python-list mailing list