Chris Angelico writes: > Possibly a better example would be path division in Python,
I would have chosen '+' for that operation for the same reason '+' "just works" for sequences. It's a very specialized use case but 5 * pathlib.Path('..') / "foo" makes sense as an operation but oh, the cognitive dissonance! It's so specialized that <0.99 wink>. '/' is fine for pathlib, and I trust Antoine's intuition that it will "work" for (rather than against ;-) pathlib users. > or stream left/right shift in C++. I'm very sympathetic to your argument for this one. > Is that abuse of notation or something else? As I wrote earlier, I don't think "abuse of notation" is a useful analogy here. > Whatever it is, it's not > "operator overloading" in its normal sense; division is normally the > inverse of multiplication, but there's no way you can multiply that by > "quux" to undo that last operation, But if you spell it '+', pathlib.Path("/") + "foo" + "bar" + "quux" - "bar" makes some sense, modulo the definition of the case with multiple "bar". I don't argue it's useful, just interpretable without head explosion. > Maybe we need a different term for this kind of overloading, where > we're not even TRYING to follow the normal semantics for that > operation, but are just doing something because it "feels right". "Overloading" for this case doesn't bother me, but if you want to introduce a new term, Greg Ewing's "operator repurposing" WFM. Steve _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/5GUDGYNX56LXLDCDD4EXJDQTVTGBNWOX/ Code of Conduct: http://python.org/psf/codeofconduct/