-
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: Allow Null-conditional operators to be lvalues #1106
Comments
Related: #737 |
I cannot agree with that. Even if I also do not think that suggested solution is better than one proposed in issue we cannot stop considering alternative opinions. Matters do not stand so well with mankind that the majority should prefer the better course: the more people do a thing the worse it is likely to be. Let us therefore inquire, not what is most commonly done, but what is best for us to do. Lucius Annaeus Seneca |
@Inzanit you are the victim of social networks. Or maybe what I said is very close to you? |
@jnm2 Pretty sure hardhub is one of Makeloft's alts lol. |
@jnm2 Maybe, I do not know. But I do not see anything except criticism in his post. I personally do not like technical idea of @reinspi. And think his solution cannot be named elegant. But I am ready for discussions. At least it is what he suggested "constructive discussions and arguments." So I appreciate any criticism independently of rudeness or vulnerability of any person of community. TAGC you are idiot (or blindman... although it is not the topic). |
@HardHub Calling someone an idiot, besides being gratuitous, violates the dotnet org's code of conduct. |
@HardHub It's not just his technical ideas. He's a sockpuppet of someone who's been banned on here for bad conduct, and doing that is unacceptable pretty much everywhere. |
@HardHub, please refrain from "personal attacks". As @jnm2 mentioned, this violates the code of conduct (specifically the "Be respectful" section) we have for this repository (and all repositories under dotnet). |
First, I do not think it is gratuitous: Second, we are on GitHub man.. and it is open-source community!
I am about only his posts in current issue (I did not see any other his posts). It is obviously only technical description of some not very good idea. I do not like to discuss it further:
Just assumption... maybe this community is too weak because it has too much MS employees...? So all what I wanted to say, I said, please, do not misinterpret my words, and on that let's finish this discussion. |
And that's fine. But this community has its own understanding as well, and those who can't hold to it don't belong here. They can take their personal understanding elsewhere. |
I have temporarily locked this thread as it is quickly becoming off-topic. CC. @richlander, @jaredpar, @gafter, @terrajobst, @jongalloway |
Considering tone & style I concluded that hardhub is another version of makeloft, I added him to the list of blocked users. Sigh. It would help our case if we collectively decided not to engage with this user any further. Arguing has shown not to work; it's just wasting time everyone's time and makes already challenging threads even harder to read. We're working with GitHub support to find a better way to deal with this but meanwhile ignoring that user, deleting any comments, and banning the user account is the way to go IMHO. So everyone: please stop feeding the troll. |
would really like this feature more than other things that are getting in C# SelectedUnit.GetComponentController<MovementComponentController>()?.MoveFinishedHandler -= SelectedUnitFinishedMoving; instead of if (SelectedUnit.GetComponentController<MovementComponentController>() != null)
SelectedUnit.GetComponentController<MovementComponentController>().MoveFinishedHandler -= SelectedUnitFinishedMoving; or var moveComp = SelectedUnit.GetComponentController<MovementComponentController>();
if (moveComp != null)
{
moveComp.MoveFinishedHandler = SelectedUnitFinishedMoving;
} |
+1 |
This is a duplicate of #2883 and since that issue is championed, I'm going to close this issue. |
@SetTrend commented on Wed Sep 21 2016
Currently you cannot assign a value to an object's property if that property may be
null
.I suggest to allow for the Null-conditional operator to become an lvalue.
This would allow for the following statement to compile without error:
Everything right to a runtime null value is suggested not to be executed/evaluated.
So at run-time, the following two statements would be equivalent, given that any of the Null-conditional operator yielded
null
:... same for function calls:
RFC
@alrz commented on Wed Sep 21 2016
Related: dotnet/roslyn#1276
@HardHub commented on Wed Nov 08 2017
It looks strange... Should you get null reference exception if myObject is null?
@alrz commented on Wed Nov 08 2017
I think we could translate the assignment operator of the form:
to a ternary of the form:
fallbackValue
is emitted asdefault(T)
whereT
is the type of that expression.fallbackValue
is emitted asdefault(T?)
whereT
is the type of that expression.Similarly, we may use
-=
and+=
(event subscription and unsubscription) operators with a conditional access on the left-hand-side (#1276), but in that case, the resultant type of the whole expression isvoid
just likevar x = obj?.Event += handler; // ERROR as you can't assign void
.This could be extended to conditional indexer access or other compound assignments too.
@SetTrend commented on Thu Nov 09 2017
@HardHub: 👍 😳
Oops ... Edited my original posting to show expected behaviour. Thanks for pointing it out!
@CyrusNajmabadi commented on Fri Nov 10 2017
x?.Foo(a1, b1, c1)
then a1, b1, c1 are not evaluated if x is null. It seems strange that inx?.y = z
that z would be evaluated if it's not going to be assigned into anything.@jcouv commented on Tue Nov 14 2017
Moving to csharplang
The text was updated successfully, but these errors were encountered: