On Oct 25, 2019, at 06:26, Serhiy Storchaka
25.10.19 15:53, Andrew Barnert via Python-ideas пише:
If you were designing a new Python-like language today, or if you had a time machine back to the 90s, it would be a different story.
Interesting, how far in past you will need to travel? Initially builtin types did not have methods or properties, and the iterable protocol did not exist.
Well, the str methods are largely carried over from the functions in the string module, which was there before 1.0. And I think the ord builtin goes back pretty far as well. So ideally, back to the start. On the other hand, it’s not like there was a huge ecosystem of third-party modules using Python 0.9 that Guido couldn’t afford to break, so If your time machine couldn’t go back quite that far, it might be ok to do it as late as, say, 2.2.
Adding this will require too much work, and I am not sure Guido would like how much complexity it adds to his simple language.
Adding it today would certainly require too much work—not so much for Python itself as for thousands of third-party libraries and even more applications, but that’s even worse. Even if it weren’t just to fix a small wart that people have been dealing with for decades, it would be too much. That’s why I’m -1 on it. But adding it in early Python would have been very little work. Just add one more builtin type, and change a dozen or so builtin and string module functions, and you’re done. And it would be very little complexity, too. Yes, it would mean one more built in type, but nothing else is complex about it. The Smalltalk guys who were advertising that their whole language fits on an index card could handle chars. And it’s not like it would be an unprecedented innovation—most languages that existed at the time, from Lisp to Perl, had strings as sequences of either chars or integers (or, as with C, of chars but char is just a type of integer). If anything, it was ABC that was innovative for making strings out of strings (although Tcl and BASIC also do); it just turned out to collide with other innovations that Python got over the next couple of years, in ways nobody could have imagined. And the hard bit would be describing what the Python 2.x language and ecosystem would look like to Guido so you could explain why it would matter. The idea that his language would have an “iterable protocol” that could be implemented by not just lists and strings but also user-defined types using special methods, and automatically by functions using a special coroutine semantics, and also by some syntax borrowed from Haskell, and that was checkable via an abstract base class using implicit structural testing…