On Thu, Nov 17, 2016 at 12:07:34PM +0900, Stephen J. Turnbull wrote: > Nick Timkovich writes: > > > I think the best way to remove compound operators would be to go > > back in time and hit Dennis Ritchie with a bat at the exact moment > > when the notion of them crosses his mind. > > True enough as a concept, but Python didn't have to implement them for > immutables. It might have been interesting to allow in-place > operations only for mutables.
By definition, you can only perform in-place operations on mutables. But I guess you are talking about the syntax. Should += raise an exception if the assignment target is immutable? Problem is, how is the Python interpreter supposed to determine whether or not the target is immutable or mutable? There's no isinstance(obj, Immutable) and I doubt there ever will be. More importantly, banning immutables would immediately prohibit the number one most common use of augmented assignment, and probably the largest motivation for the feature: x += 1 > Dunno if Guido thought of that at the time, and I suspect that a lot > of the voices that convinced him to go against his instincts wanted > them specifically for integers (a lot of people wanted "++" and "--", > too). So even if he did think of it, it might not have satisfied the > proponents that their needs were being addressed. Indeed. Supporting `alist += [x]` but not `x += 1` would have been deeply unsatisfactory. I think the status quo is actually very clever: augmented assignment is broadly equivalent to the expanded assignment: obj += foo => obj = obj + foo except that the target obj has the opportunity to optimize it to an in-place operation, even if that makes the semantics slightly different from the ordinary & operator. > > Except Perl. > > Please don't. I don't think there is any need for that. No harm is done by a little light-hearted banter relating to the rivalry between programming language communities. In the big picture, a bit of friendly rivalry probably does both communities good. Regardless of what virtues Perl may or may not have, in some ways the philosophy behind Perl is dramatically opposed to that of Python. Many of us like Python code because it goes against Perl's ideals. We discourage many of the things that Perl and its culture encourages: terse, long one-liners, heavy use of regexes, heavy use of sigils and symbols, "clever" code, and More Than One Way To Do It. There's a natural rivalry between Perl and Python. We should be permitted to criticise other languages, and even dismiss them as useless. Programming languages do not have the assumption of dignity owed to human beings. Nick's dismissal of Perl was obviously intended as light-hearted and not entirely serious. This is an informal forum, a mailing list, and throw-away comments intended as humour shouldn't be held to the same standard as serious statements intended as part of a logical argument. Had Nick said "Python should not do X, because Perl does it and nothing Perl does is of any value at all" then we'd be justified in asking him to defend his claim, or to simply dismiss it as obviously ridiculous. But he didn't. I doubt Nick meant that Perl was literally lacking in any redeeming features: exaggeration and hyperbole are time-honoured forms of humour. His comments weren't disruptive and they most certainly were not attacking anyone. It would require the most extraordinarily thin skin to take that as an attack against people who use Perl, and even if somebody did, well, this is not a support group for people so lacking in self-esteem that their self-image is equated to their choice of programming language. (I believe we've already had to ban, or at least warn, one regular to this list under the terms of the CoC, because he couldn't distinguish ill-founded criticism of Python the language from criticism of the people designing and using the language, and he responded with personal attacks.) I'm sorry that I've written more words defending Nick's throw-away two word comment than you expended in lightly chastising him. But I didn't want to just say that I disagreed with you -- I wanted to give the reasons why I support our right to light-heartedly disrespect other languages. (And of course you're right, Python has borrowed regular expression syntax and the Cheeseshop from Perl, and possibly more.) -- Steve _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/