▲ | bandyaboot 5 days ago | |||||||||||||||||||||||||||||||
I’m having a hard time imagining where this is useful. If I’m trying to assign to a property, but encounter an intermediate null value in the access chain, just skipping the assignment is almost never going to be what I want to do. I’m going to want to initialize that null value. | ||||||||||||||||||||||||||||||||
▲ | Metasyntactic 4 days ago | parent | next [-] | |||||||||||||||||||||||||||||||
Hi there, one of the lang designers here :) Think of it this way. We already supported these semantics in existing syntax through things like invocations (which are freely allowed to mutate/write). So `x?.SetSomething(e1)`. We want properties to feel and behave similarly to methods (after all, they're just methods under the covers), but these sorts of deviations end up making that not the case. In this situation, we felt like we were actually reducing concept count by removing yet another way that properties don't compose as well with other language features as something like invocation calls do. Note: when we make these features we do do an examination of the ecosystem and we can see how useful the feature would be. We also are community continuously with our community and seeing just how desirable such a feature is. This goes beyond just those who participate on the open source design site. But also tons of private partners, as well as tens of thousands of developers participating at our conferences and other events. This feature had been a continued thorn for many, and we received continuous feedback in the decade since `?.` was introduced about this. We are very cautious on adding features. But in this case, given the continued feedback, positive reception from huge swaths of the ecosystem, minimal costs, lowered complexity, and increased consistency in the language, this felt like a very reasonable change to make. Thanks! | ||||||||||||||||||||||||||||||||
▲ | moogly 5 days ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||
I'm also not sure I have a lot of code where this would be useful, but adding it to the language I don't feel makes it worse in any way; in fact, it makes it more consistent since you can do conditional null reads and conditional null method invocations (w/ `?.Invoke()`), so why not writes too. | ||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||
▲ | Quarrelsome 5 days ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||
improving crappy codebases without breaking anything. Bad .NET developers are forever doing null checks because they write weird and unreliable code. So if you have to fix up some pile of rotting code, it can help you slowly iterate towards something more sane over time. For example in my last gig, the original devs didn't understand typing, so they were forever writing typing code at low levels to check types (with marker interfaces) to basically implement classes outside of the classes. Then of course there was lots of setting of mutable state outside of constructors, so basically null was always in play at any moment at any time. I would have loved this feature while working for them, but alas; they were still on 4.8.1 and refused to allow me to upgrade the codebase to .net core, so it wouldn't have helped anyway. | ||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||
▲ | 5 days ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||
[deleted] | ||||||||||||||||||||||||||||||||
▲ | 5 days ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||
[deleted] | ||||||||||||||||||||||||||||||||
▲ | 5 days ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||
[deleted] | ||||||||||||||||||||||||||||||||
▲ | mkoubaa 5 days ago | parent | prev [-] | |||||||||||||||||||||||||||||||
Monad-maxxing has ruined many a language | ||||||||||||||||||||||||||||||||
|