Static typing (was Re: Java guy interested in Python)
D-Man
dsh8290 at rit.edu
Fri Mar 9 11:27:34 EST 2001
On Fri, Mar 09, 2001 at 09:52:09AM +0000, Hamish Lawson wrote:
| Michael Hudson wrote:
|
| > If you type-annotate this, you might write (using entirely made up
| > syntax):
| >
| > def write16(file : <file>, int : <int>):
| > file.write(struct.pack("h",int))
| >
| > but then what about passing in a StringIO object, or some user
| > wrapper of a file object? What makes a "<file>"? At the moment,
| > it's just a loose collection of methods, some of which are optional
| > in some circumstances.
|
| Wouldn't there be a hierarchy of interface types for file-like objects,
| with some interfaces specifying more methods than others? You'd then
| choose the interface type that specified the collection of methods that
| you require of your passed object.
Yes. It's called Java ;-).
|
| Not-that-I'd-necessarily-want-this-all-of-the-time-ly yours,
I certainly don't.
I do like the ERR side of compile-time type checking however. Perhaps
someone should create a Py-lint that will check python source for this
sort of thing. Then again maybe it's already called PyUnit or
doctest.
-D
More information about the Python-list
mailing list