On 2018-05-15 00:52:42 +0000, Steven D'Aprano wrote: > Now remember that in 1991 when Guido made the decision to ban = as an > expression, those concepts didn't even exist. There were no Python > linters, and no reason to imagine that there ever would be. Guido didn't > know that Python would become one of the top 10 most used languages. For > all he knew, version 1.0 could be the final release. > > By 1991 there had already been *decades* of experience with C
About one and a half decades. > proving that the "=" assignment syntax is dangerously confusable with > == and a total bug magnet when allowed as expressions as well, so it > was perfectly reasonable to ban it from the language. Experience? Yes. Data? I doubt it. I will readily admit that my knowledge of research into the usability of programming languages is more than spotty, but I have read a few papers about the topic over the last decade. I don't recall any which quantified "bug magnets" under realistic conditions (two hour toy problems for first-year students don't count). I thought there was one by Google, but that was about compile-time errors. Language design ist still mostly an art driven by gut feeling, not engineering driven by data. I doubt that this was better in 1991. I have been programming in C since the mid-80's and in Perl since the mid-90's (both languages allow assignment expressions). I accumulated my fair share of bugs in that time, but AFAIR I made this particular error very rarely (I cannot confidently claim that I never made it). Clearly it is not “a total bug magnet” in my experience. There are much bigger problems in C and Perl (and Python, too). But of course my experience is just that of a single programmer (or a handful if I include people whose code I've reviewed or debugged) and in any case just anecdotal. (Could I quantify even my own experience? I guess I could write a script which searches through all my repositories for changesets where “=” was replaced by “==”. Not sure what that would prove.) OTOH, despite having used C and Perl long before Python, I don't miss assignment expressions. Every language has its idioms, and just because you write stuff like “if ((fd = open(...)) == -1)” a lot in C doesn't mean you have to be able to write that in Python. hp -- _ | Peter J. Holzer | we build much bigger, better disasters now |_|_) | | because we have much more sophisticated | | | h...@hjp.at | management tools. __/ | http://www.hjp.at/ | -- Ross Anderson <https://www.edge.org/>
signature.asc
Description: PGP signature
-- https://mail.python.org/mailman/listinfo/python-list