The PEP combines ideas from several different languages. For example:
* Both Dart and C# have "x ?? y" and "x?.y". * Dart has "x ??= y" and C# does not. * C# has short circuit semantics for "?." and Dart does not. * PHP has "??" but does not have "?." * Etc.
Wikipedia lists a lot of other languages, but I don't have enough personal experience with any of them to cite them in the PEP. This is why I use the phrase "other mainstream languages" multiple times.
If you think the safe navigation operator isn't presented clearly, I am willing to improve it. Is there a particular example that you're struggling with? The simplest explanation is that it works the way you would want it too, e.g. in "foo?.bar.baz", we don't want semantics that could lead to looking up "baz" as an attribute of None. Therefore, if "foo?.bar" evaluates to None, then ".baz" is short circuited — that attribute is not looked up.
On Mon, Oct 31, 2016 at 12:33 PM, Paul Moore email@example.com wrote:
On 31 October 2016 at 15:51, Mark E. Haase firstname.lastname@example.org wrote:
Therefore, I have updated the PEP with the punctuation mentioned above,
at this point the PEP can't go any farther. If the best spelling for this new operator is unacceptable, then there's no getting around that. This
should be rejected.
While I agree that there's little point arguing over spelling here - if the ? spelling is unacceptable we should just reject - I'm not sure that's the only sticking point remaining here. I still find the short-circuiting behaviour of ?. (and ?[) to be pretty confusing - and the fact that there's a long paragraph describing the behaviour, with lots of examples of the form "if you think that this example works like so, then you're wrong, and it actually does the following", suggests to me that I'm not going to be the only one struggling. Hopefully, the problem is simply the way the behaviour is presented, and a reworking of the description would make it all crystal clear - but it feels to me that there's some inherent complexity here that's an actual issue with the proposal.
Having said that, it appears that the proposed behaviour is the same as in C# (can you just come out and say "C#", rather than hinting with the phrase "other popular languages" - if we're stealing the behaviour as is from C#, let's say so, and if not, can you include examples from more than one language?) Assuming that's the case, then the fact that it's not causing confusion to C# programmers is a definite point in its favour.