Added: LDM notes for June 17, 2020 #3589
Replies: 7 comments
-
The biggest argument for |
Beta Was this translation helpful? Give feedback.
-
I really like |
Beta Was this translation helpful? Give feedback.
-
I too would prefer that syntax, as it makes clear there will be an exception at runtime and uses familiar constructs. But I do fear this might be a case of "making the feature stand out" bias. public void ProcessPayments(IReadOnlyList<Payment> payments ?? throw, Person sender ?? throw, Person receiver ?? throw) { ... }
//vs
public void ProcessPayments(IReadOnlyList<Payment> payments!, Person sender!, Person receiver!) { ... } One aspect to consider here is that with NRTs (ideally) these checks should only be performed at API boundaries, thus making them more visible and differentiating "caller is trusted" and "caller is not trusted" might actually be a good thing. The verbosity in this case should also not be that big of a problem since it is still much shorter then the custom check and public methods are not as numerous as internal/private ones. |
Beta Was this translation helpful? Give feedback.
-
@SingleAccretion I dislike scrolling horizontally so I'd probably go with the following style anyway.
So the following wouldn't be much of an issue:
But some people dislike this style so I can see why they might not be in favour of this. |
Beta Was this translation helpful? Give feedback.
-
I like the idea of having a nullable "unwrap" syntax that can be used in expressions that would not only silence the compiler but also throw if the expression is |
Beta Was this translation helpful? Give feedback.
-
For I know that you typically try to reuse keywords where possible but eventually it's going to seem like forcing too much into a single keyword/token. I think that the best and perhaps most obvious choice is The one option I would be absolutely against is the attribute version (a). I feel too much is beginning to require attributes, especially with NRTs. It's either a language feature or its not--and while the attributes are used by the compiler they look and feel like they aren't actually part of the language. Another option could maybe be |
Beta Was this translation helpful? Give feedback.
-
I don't like |
Beta Was this translation helpful? Give feedback.
-
C# Language Design Notes for June 17, 2020
Records:
1. Null-suppression & null-conditional operator
2.
parameter!
syntax3.
T??
Beta Was this translation helpful? Give feedback.
All reactions