
On Sep 28, 2015, at 09:02, Jeff Hardy <jdhardy@gmail.com> wrote:
It's worth reading the C# design team's notes and subsequent discussion on the associativity of "?." [1] since it goes around and around with no really good answer and no particularly intuitive behaviour.
Many of the problems raised there are irrelevant to Python: the fact that C# has "value types" that aren't referenced and can't be null, the fact that its ASTs are often processed by type-driven programming, the fact that it's not considered normal to raise and catch an exception in cases that aren't truly exceptional, the fact that there's (human-reader) ambiguity with ?:, the fact that . and [] are actually operators rather than a different kind of syntax, etc. There may be parallel problems to some of those issues in Python, but just assuming there will be because there are in C# doesn't establish that. The one argument that does carry over is that the "right-associative" version is harder to implement. That's worth discussing in Python terms, but it would be much more useful for someone to write an implementation to prove that the grammar, AST, and compiler code actually aren't that complicated, than to argue that they wouldn't necessarily be so. (The fact that it's harder to see where the exception comes from in something like spam(a?.b.c) is also the same in both languages, but that's already been discussed here, and I don't think that's a real problem in the first place--after all, a.b.c already raises an AttributeError that makes it just as hard to see whether it comes from None.b or None.c.)