Safe navigation operator
brian.goetz at oracle.com
Wed Jan 16 19:53:09 UTC 2019
Yes, of course it has been discussed before — many, many times.
As a language feature, it clears the already-high bar of “not a dumb idea.” (You’d be surprised at what percentage of proposed features do not clear this bar.) So, I hear you ask, then why haven’t we done it already? Because even the not-dumb ideas have to clear a much higher bar to get into the language. And there are many reasons why we might not, even though other languages have demonstrated that it is a workable and arguably useful feature.
(If you are under the impression that this is a “small tweak”, please delete that notion from your head now :)
One reason why I would not consider this feature at this point is that it is useless if the type of the field being referenced is a primitive; in order to make this feature not do something silly at this point, we’d need nullable primitives types (`int?`). C# went this way, and its a valid way, but it’s not a small tweak.
I think your main argument is “a lot of people like it.” Which is true. Which is to say, it has a benefit. But we cannot possibly do every feature that has a nonzero benefit; even if the costs were zero (which they are not), the complexity of the language would explode. So we have to make these decisions on the basis of evaluating whether a given feature offers us the best return on effort, cost, and complexity.
I think this is an OK feature, but I would rather spend my budget on pattern matching, records, value types, and specialized generics.
Hope this helps,
> On Jan 16, 2019, at 10:13 AM, Jeyvison Nascimento <jeynoronha at gmail.com> wrote:
> Hi Folks :)
> Not sure if this is the best mail list to start it but I'd like to start a
> discussion about safe navigation operator (i.e "?." in Kotlin) in java.
> Not sure if this was already talked about but if it wasn't I think it's
> something worth to investigate and explore.
> What do you people think about it?
> Jeyvison Nascimento
More information about the amber-dev