This project is read-only.

What's official name of '?.' ?

Topics: General
Nov 21, 2014 at 1:58 AM
var length = person?.Name?.Length;
This feature which is known as 'null-propergation operators' or 'null-conditional operators' is so great. However, we don't know the correct name.

Please tell us official name.
Nov 21, 2014 at 2:06 AM

Almost in the past documents included this discussion forum 'null-propergation operators' is used, but in some recent documents 'null-conditional operators' is used as below.
I'm now preparing materials for explaining C# 6.0 features, so I'd like to know the official name.
Nov 23, 2014 at 5:28 AM
The only way to know for sure is to wait for the publication of the revised language specification, and that won't happen for months.

I know that's not a very helpful answer, but I imagine that this is the kind of thing that is likely to change.
Nov 23, 2014 at 1:48 PM
Last spring while discussing whether to change the associativity of this feature, Bill McCarthy suggested that with the change it was no longer propagating the nulls, but rather the reverse and suggested that null-propagation and null-conditional represented the two approaches much more clearly than left/right associativity which it seems everyone (even Lucian) was taking turns getting backwards (causing the discussions to be even more confusing than they were.

I don't know what will be official, but "null-propagation" is a legacy name having nothing to do with the current implementation.

Null conditional is a better name, and "Elvis operator" is likely to get traction as well.
Nov 24, 2014 at 9:50 AM
Did someone say beetlejuice???

I'd vote for "null truncating operator"
Nov 24, 2014 at 6:01 PM
I'd refer to it as a the "null-safe dereferencing operator".
Nov 25, 2014 at 12:07 AM
I'd recommend avoiding terms such as "referencing" or "dereferencing" as they have quite different connotations in other languages (especially C based languages). For example, if it was "derefencing" and the left operand was a nullable structure such as geolocation, would setting a member such as the longitude actually be changing the value in the operand's member or a copy ? If it was "dereferencing" I'd expect the later, which would be otherwise totally unexpected ;)

I'd much rather see terms such as "short-circuit" or "truncate" as they are also clearly indicative that the null is returned there, not further propagated. I don't like the term short-circuit as much as truncate, because to me a "short circuit" is usually a bad bad thing (sometimes associated with acrid smoke).

So the long handed version would be "null truncating member access operator", or NTMAO or NTO for short ;)
Nov 25, 2014 at 10:05 AM
<fun>Aaaaaah! We tried this already to find a name for "internal and protected" and the feature got removed. Please let's not play this game again.</fun>
Nov 25, 2014 at 10:10 AM
Shouldn't the name given by the first inventor be used?

So far I have heard of Coffeescript's version:
"The accessor variant of the existential operator ?. can be used to soak up null references in a chain of properties."
zip = lottery.drawWinner?().address?.zipcode