Live data from Hacker News

What’s New in C# 7.0

blogs.msdn.microsoft.com

21–30 of 278 posts

Re: What’s New in C# 7.0

#21

Like everything except "Ref returns and locals". I don't think I've ever seen a case where I wished for that feature. All the other things - tuples, anonymous out vars, pattern matching - I've found myself wanting quite often.

I believe ref returns are a performance feature. They seem a bit like move constructors in C++ in that they can save you a copy? But I am not confident I understand the nuances of move constructors to compare them properly.

They don't move anything, they are either pointers to a value on the stack or to a field in an object on the heap. The first is more like how standard C++ references are usually used, and the second are interior pointers like Go has. No code gets executed to make them happen, and no data is copied.

Re: What’s New in C# 7.0

#22

Like everything except "Ref returns and locals". I don't think I've ever seen a case where I wished for that feature. All the other things - tuples, anonymous out vars, pattern matching - I've found myself wanting quite often.

I believe ref returns are a performance feature. They seem a bit like move constructors in C++ in that they can save you a copy? But I am not confident I understand the nuances of move constructors to compare them properly.

[deleted]

Re: What’s New in C# 7.0

#25
post #19

Since C# is starting to look more like JavaScript (i.e. local functions) and vice versa (i.e. arrow aka lambda expressions). I'm going to throw my pocket change into a couple features I've been growing old hoping to see: 1. Regex expressions just like Regexp in JS: /^\s+$/.IsMatch(" "); // or Regex r = /^\s+$/; 2. DateTime expressions, similar to regex, something like: DateTime clockTowerLightning = #1955/11/12 10:04…

To be clear, local functions long predate Javascript. Though a handy regex notation would be nice, I could've used that on a couple projects that I had (corporate environment) to do in C# when it wasn't really best suited to the task (at least in terms of brevity/clarity compared to other languages like python or perl for generating reports and similar behaviors.

Re: What’s New in C# 7.0

#26
Pattern matching! Tuples! Awesome, C# 7.0 is scratching two itches I've felt every time I've worked with it.

If only .NET had a suitable cross-platform UI toolkit, then I'd be using it everywhere. Eto.Forms is a good attempt but I found rather buggy and limited at this point in development. Avalonia, while further along in terms of stability and features, doesn't even try to fit in with any platform's look and feel.

Re: What’s New in C# 7.0

#27
post #19

Since C# is starting to look more like JavaScript (i.e. local functions) and vice versa (i.e. arrow aka lambda expressions). I'm going to throw my pocket change into a couple features I've been growing old hoping to see: 1. Regex expressions just like Regexp in JS: /^\s+$/.IsMatch(" "); // or Regex r = /^\s+$/; 2. DateTime expressions, similar to regex, something like: DateTime clockTowerLightning = #1955/11/12 10:04…

DateTime literals... something I wish C# would borrow from VB.NET

Re: What’s New in C# 7.0

#28

In the binary literal proposal there is also some unresolved discussion about octal support, chip in if you like: https://github.com/dotnet/roslyn/issues/215

I wish more languages would take a radix-agnostic approach (at least to a reasonable limit). What's wrong with:

  2#1010101
  8#75342
  1341235
  10#13451
  16#feb1300
radix#value, from erlang.

Or:

  #b10101
  #xfefe
  #o7777
  #36rSSSS
From common lisp.

Customize in some fashion for C# and its current notations for hex and (now) binary literals.

  036rSSSS
  02r10101
  0b10101 // this and above are equal

Re: What’s New in C# 7.0

#29
post #20
post #7

It looks like they've added a lot of rope to hang ourselves with typos. int myvar, I; foo(out int mvar); // oops, not myvar; maybe caused by a refactor? bar(out *); // oops, not I; was up too late coding And so on. Things like this would be easily missed when reading code at-a-glance, and it's this sort of bug that arises often in languages that allow implicit declaration of variants.

> foo(out int mvar); // oops, not myvar; maybe caused by a refactor? This should fail to compile, it's the equivalent of declaring a variable twice int the same scope.

If that were int myvar you'd be correct, in this case the typo introduces a new variable mvar that won't conflict with the original declaration.

Re: What’s New in C# 7.0

#30

Pattern matching! Tuples! Awesome, C# 7.0 is scratching two itches I've felt every time I've worked with it. If only .NET had a suitable cross-platform UI toolkit, then I'd be using it everywhere. Eto.Forms is a good attempt but I found rather buggy and limited at this point in development. Avalonia, while further along in terms of stability and features, doesn't even try to fit in with any platform's look and feel.

Feels kinda crazy to see tuples and pattern matching "just arrive" when other languages have had them for years.
Post reply on HN