"no variable or argument declarations are necessary."

Diez B. Roggisch deets at web.de
Fri Oct 7 08:21:59 EDT 2005


> Now some of the Python-is-perfect crowd seems to suffer from a "Blub
> paradox" (http://c2.com/cgi/wiki?BlubParadox).  They see annoying,
> static typed languages like C and Java, and they see pleasant,
> dynamically typed languages like Python, and conclude that static
> types = annoying, when in fact they can be orthogonal.  So, can there
> be a language that's both statically typed, and pleasant?  I haven't
> used one yet, but lately I've been reading about Haskell and want to
> give it a try.

Nobody says that there can't be possibly better languages like python
overall, or for specific tasks. However, this discussion is about
introducing type-checking to python. And as someone who has done his
fair share of FP programming let me assure you that

 - all declarations are fully type annotated. The inference only comes
into play on _expressions_. The result in python would be that you'd
have to write

def foo(x:int):int :
     return 10

but then could use

x = foo()

which made the inference possible. But it _doesn't figure out that foo
returns an int because there is one returned, and misses the :int in
the declaration! Genericity is reached through solving somewhat more
complicated type equations - but these still require declarations:

def bar(l:list[whatever]):whatever :
     return head(l)

x = bar([10])

can be resolved as [] will me a list-constructor that gets passed an
int literal - wich in turn means that whatever as type-variable is
bound to int, and thus x is an int, as that is the return type of bar.

 - FPs share their own set of problems - try writing a server. The have
inherent troubles with event-driven programs. Then you need monads, and
that makes things a little bit more ugly...

Still, FP is cool. But python too. And just attaching some
type-inference to python won't work.

Diez




More information about the Python-list mailing list