Next step after pychecker

Philippe Fremy phil at freehackers.org
Tue Feb 1 18:28:28 EST 2005


> I do not want to discourage Philippe Fremy but I think that this would be very 
> very difficult to do without modifying Python itself.

That's the conclusion I reached to too after lurking on the ocaml list.

> 
> What FP languages rely upon to achieve type inference is a feature named 
> "strong typing". 
 > [...]
>
> This is certainly not the case for Python since one and the same variable can 
> have different types depending upon the execution context. Example :
> 
> 1- if a is None:
> 2-   b = 1
> 3- else:
> 4-   b = "Phew"
> 5- b = b + 1
> 
> One cannot statically determine the type of b by examining the line 5- alone.
> 

There are even worse cases:

1- a=1
2- a= someObject.someMethod()

someObject might not have someMethod() and this would be caught by an 
AttributeError exception handler and 'a' will stay at 1.


> Therefore, Fremy's dream can very well turn to some very complex expert system 
> to make "educated" warning. Being "educated" is a lot harder than to be 
> "brutal".

And even being brutal is not that easy to achieve...

> Anyway, strong typing as defined above would change the Python language in 
> some of its fundamental design. It would certainly be valuable to attempt the 
> experience, and rename the new language (mangoose would be a pretty name).

Indeed. I understood that this is one of the things that could be 
provided by pypy.

What I understood (Jacek, this is an answer for you too) is that there 
are many usage patterns for python.

Some people use it for all of its advanced dynamic features. I use it in 
a java-like fashion. One could use it without the "OO crap", like a 
modern pascal replacement.

This is a strength of python that it lends itself to so many programming 
paradigm. However, one drawback is that python is not optimum in many of 
these paradigm (although it is sometimes the best proponent). In my 
case, dynamic typing is not a required feature. Typing immutability and 
type inferring is a lot more valuable.

I really hope that pypy will provide that kind of choice. Give me python 
with eiffel like contracts, super speed optimisation thank to type 
inference and I will be super happy.

Thank everyone for its feedback.

Any other idea of a fun python improvement project I could join without 
too much hassle ? I can't help but thinking that pychecker ought to be 
able to do a better job.

	regards,

	Philippe



> 
> Francis Girard
> FRANCE
> 
> Le mardi 1 Février 2005 16:49, Diez B. Roggisch a écrit :
> 
>>>But it can be useful to restrict type variety in certain situations
>>>e.g. prime number calculation :) And it would probably also be useful
>>>to check violations of restrictions before running the program in
>>>normal mode.
>>
>>But that's what (oca)ml and the like do - they exactly don't force you to
>>specify a type, but a variable has an also variable type, that gets
>>inferned upon the usage and is then fixed.
>>
>>--
>>Regards,
>>
>>Diez B. Roggisch
> 
> 



More information about the Python-list mailing list