News for hackers. Stuff that matters.
Re:Welcome to C# 9.0 by daeken on Wednesday May 20, 2020 @02:56PM (#23250420)
Damn, this is fantastic. One big syntactical thing I should really put in a proposal for is null-conditional returns. Turning

    if(foo != null) return foo;
Into

    return? foo;
It fits perfectly with the existing null coalescing operators and such, while really cleaning up a lot of code.
Re:Welcome to C# 9.0 by kungato on Wednesday May 20, 2020 @03:42PM (#23250899)
This look so very prone to cause bugs. Why would you even "return if not null"? I don't think I've been in this situation before. What I do see is if x is null then return something else, but this never
Re:Welcome to C# 9.0 by topkai22 on Wednesday May 20, 2020 @05:41PM (#23252173)
I think return is too important a keyword to make optional like that. However, I could totally get behind a shortening like

if(?foo){return null}

Re:Welcome to C# 9.0 by Koshkin on Wednesday May 20, 2020 @06:05PM (#23252506)
An interesting idea; it could be extended to other constructs - assignments, method calls... Also, imagine having something like this:

  while (!return? foo) {
    foo = get_foo();
  }
Re:Welcome to C# 9.0 by oaiey on Thursday May 21, 2020 @02:27AM (#23255428)
Oh please not. Hiding complexity is dangerous.
Re:Welcome to C# 9.0 by bradford on Wednesday May 20, 2020 @05:26PM (#23251986)
I'm confused. In the first code block, what value is returned if foo is equal to null?

If it returns null, what's the difference between:

>return foo;

and

>return? foo;

?

Re:Welcome to C# 9.0 by mgamache on Wednesday May 20, 2020 @03:15PM (#23250609)
I am surprised that hasn't been done already.
Re:Welcome to C# 9.0 by u7u7h on Wednesday May 20, 2020 @03:35PM (#23250826)
Better not.
Re:Welcome to C# 9.0 by dullgiulio on Wednesday May 20, 2020 @03:47PM (#23250943)
Perl# basically.