|
|
Log in / Subscribe / Register

Opposition to Python type hints

Opposition to Python type hints

Posted May 7, 2015 10:12 UTC (Thu) by jezuch (subscriber, #52988)
Parent article: Opposition to Python type hints

> writing signatures that are both sufficiently open to be back-compatible and sufficiently restrictive to be able to catch bugs seems like it might be very nearly impossible

This is a general problem with adding things to an existing language that might not be exactly in line with its existing "ethos". When generics were introduced to Java, the standard library was retro-fitted to include type parameters on such essential types as the java.util.Map interface. But while they made the put() method to be put(K key, V value), the remove() method remained remove(Object key). The thinking was, AFAICT, that you should be able to remove anything from a collection - if it's a wrong type, it just won't be there. And also, backwards compatibility with some (IMO) dumb code that mixes types of keys. So now we're stuck with this... thing that in the best case is really annoying and in the worst case is a major source of bugs. Yes, tools like findbugs will point out where incompatible types are passed to remove(), but I shouldn't need a special static analyzer tool to avoid stupid bugs like that...

/rant :)


to post comments


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds