Il 06/10/2017 00:06, Jesper Steen Møller ha scritto:
In other words, IMHO a?.b.c should implicitly mean a?.b?.c or at least give a warning that the construct doesn't make sense. In either case ??. wouldn't make much sense.

I perfectly agree with this, I always wondered why it was chosen to require all those "?" on all steps of the navigation. Shil is right about the possible use of exceptions for control flow, but how often one can be so wicked to really need "a?.b.c" instead of "a?.b?.c"?

Il 06/10/2017 01:12, Jochen Theodorou ha scritto:
I personally think we made a mistake with ?. Instead of safe navigation, we should stop evaluation

x = a?.b?.c?.d

is translated as:

var tmp
tmp = a==null?null: a.b
tmp = tmp==null?null: tmp.c
tmp = tmp==null?null: tmp.d
x = tmp [cut]
while x = a??.b.c.d is

var tmp
tmp = a==null?null: a.b.c.d
x = tmp

So are you saying that "a??.b.c" is NOT equivalent to "a?.b?.c"? With this implementation of  "??", a NPE is thrown if a is not null but a.b is...

Mauro

Reply via email to