-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: null-conditional call #261
Comments
Func<int, string> myFunc = null;
if (myFunc?.Invoke(10) == null)
{
Console.WriteLine("Every body happy now");
} |
Probably I need some sleep. :) |
AFAIK This was considered in the design of C# 6.0 and discarded because of ambiguities with ternary. |
Then closing it. |
@alrz Please provide some case, where it gives ambiguity. If you remember. |
Probably it was declined due to cost/scheduling more than ambiguity? |
I remember the ambiguity too. Plus, writing out |
@dmitriyse |
Good example, thanks. |
@ufcpp what ambiguity?
|
The problem is that whne you see the ?( you don't have enough information to make the determination. The part that follows the ?( may be arbitrarily complex. This means you'd have to do an enormous complex scan (or an expensive speculative parse) to figure out what was going on. For example, if you had: f?(a, b).ToString() What is? Well, you still can't tell. Maybe it's your new nullable-call, or maybe it's a ternary that has a tuple on the 'true' side. Given that you have full expression facilities available to you (i.e. 'a' and 'b' can be arbitrarily large), it's quite difficult to make a determination about what's going on. Remember that resolving ambiguities doesn't mean just handling the simple case. It means handling all the cases :) |
Brilliant, thank you! I knew I was missing something :)
…On 10 Nov 2017 8:39 pm, "CyrusNajmabadi" ***@***.***> wrote:
The problem is that whne you see the ?( you don't have enough information
to make the determination. The part that follows the ?( may be arbitrarily
complex. This means you'd have to do an enormous complex scan (or an
expensive speculative parse) to figure out what was going on. For example,
if you had:
f?(a, b).ToString()
What is? Well, you still can't tell. Maybe it's your new nullable-call, or
maybe it's a ternary that has a tuple on the 'true' side.
Given that you have full expression facilities available to you (i.e. 'a'
and 'b' can be arbitrarily large), it's quite difficult to make a
determination about what's going on.
Remember that resolving ambiguities doesn't mean just handling the simple
case. It means handling all the cases :)
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#261 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAOoMY1oKYCyAzgbmGaGuyhAGD50CE4uks5s1LSWgaJpZM4MbPQV>
.
|
You're welcome :) |
The text was updated successfully, but these errors were encountered: