Adding static typing to Python
Laura Creighton
lac at strakt.com
Thu Feb 21 02:50:03 EST 2002
More information about the Python-list mailing list
Thu Feb 21 02:50:03 EST 2002
- Previous message (by thread): Adding static typing to Python
- Next message (by thread): Adding static typing to Python
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> Alexander Jerusalem: > The proposals of the types-SIG say that static typing is used on a per > module basis. That means that weather there is or is not a performance > improvement it's only going to affect you if you choose to use the > static types. > > Alexander The problem is that static typing effects everybody in terms of code reusability. Let us say you make a terrific function which works on a string. And in some way you specify that, yes, the first and only argument to this function is a string. Now, let us assume I love your function and want to use it a lot. But I want to use it on my own objects which are in some way 'string like'. Right now I have to read your code, and determine what were the properties of a string you used, to determine whether my stringlike object can already be used with your function. I would like to automate this, and be able to interrogate both your function and my object and get a result 'will work' or 'won't work: reason object does not have an islower method which function requires' and the like. What I don't want to have to do is rewrite the code, because Alexander Jerusalem was only thinking about strings when he wrote it. Static type checking makes you think that 'strings' and 'ints' and the like a real meaningful things rather than a convenient shorthand for 'is a sequence and has the following methods': ['capitalize', 'center', 'count', 'encode', 'endswith', 'expandtabs', 'find', 'index', 'isalnum', 'isalpha', 'isdigit', 'islower', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'replace', 'rfind', 'rindex', 'rjust', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper'] See 'PEP 246: Object Adaptation - (Clark C. Evans)' http://python.sourceforge.net/peps/pep-0246.html for one attempt to get the safety you want without the restriction I don't. Laura Creighton
- Previous message (by thread): Adding static typing to Python
- Next message (by thread): Adding static typing to Python
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list