News for hackers. Stuff that matters.
Re:New Features in C# 7.0 by divanvisagie on Thursday March 09, 2017 @11:56PM (#13836482)
This language is called C# because you know... C. out variables are there because people were used to coding like this and now that it's there it would just break things to remove it from the language, so you might as well just make it a bit cleaner.
Re:New Features in C# 7.0 by pmarreck on Friday March 10, 2017 @12:01AM (#13836507)
Fair enough.

But people should stop coding like this. For the love of all that is good and binary, don't use arguments to mutate values in the same scope. Just return them and reassign them. That way, state flow is always in via the arguments and out via the return value(s). Without this discipline, you will have a hodgepodge of "value flows" and that complexity will kill you when debugging. When new values can be spit out both by function returns and function arguments... Hold on, I have to take an aspirin

I know that a lot of OO/procedural languages permit you to do this (unfortunately). Don't!

Re:New Features in C# 7.0 by divanvisagie on Friday March 10, 2017 @12:40AM (#13836649)
Yeah , I get you , this coding style is horrible. I personally try to avoid mutating things as much as possible. I wonder how long we will have these old artifacts around before we decide that things need to move to newer langs like F# instead of tacking new features onto the existing lingua franca of .NET.
Re:New Features in C# 7.0 by gokhan on Friday March 10, 2017 @01:42AM (#13836831)
Been using c# since the day 1, almost never seen someone designing from the ground up with out parameters for the last 10 years. They're not that common. I guess it looks like a favorite feature in the document because it takes the largest part of it, it's not.
Re:New Features in C# 7.0 by tigershark on Friday March 10, 2017 @10:54PM (#13844126)
Never used a concurrent dictionary or an IDictionary trying to be sanely efficient using TryGetValue instead of ContainsKey followed by a call to the accessor? I can't really believe that you started using c# from the day one and you never encountered an hot code path with a TryGetValue. Of course it gets much worse when you have millions of objects, but even with hundred of thousands it is kind of noticeable. Unless you don't care about caching at all, but that is a complete different kind of dragons'lair...
Re:New Features in C# 7.0 by mercurial on Friday March 10, 2017 @12:52AM (#13836686)
> out variables are there because people were used to coding like this

This does not invalidate OP's point that it is terrible design. You do not need to take every bad idea in older languages in the name of familiarity.

Re:New Features in C# 7.0 by olavk on Friday March 10, 2017 @02:29AM (#13836975)
I believe it is for interoperability with code in these languages, not just familiarity. That said, the BCL also use out parameters in a few places (the TryParse methods) which arguable set a bad precedent.