The Future of C# with Mads Torgersen: C# 6

 

Copy/paste from http://adamralph.com/2013/12/06/ndc-diary-day-3/

The NDC Wi-Fi was put to the test during this talk with the C# Twitter stream seeing an explosion in traffic as Mads revealed, for the first time publicly, a range of features either set to be delivered in the next version of C# or at least under strong consideration.

Unfortunately I was too caught up in the excitement to note everything down but after mining my memory and the Twitter feed, here is the list of implemented/potential language features (I’m sure I’m missing at least one of them):

  • primary constructors – public class Point(int x, int y) { }
  • read only auto-properties – public int X { get; } = x;
  • static type using statements – using System.Math;
  • property expressions – public double Distance => Sqrt(X * X + Y * Y);
  • method expressions – public Point Move(int dx, int dy) => new Point(X + dx, Y + dy);
  • params for enumerables – public Point Average(params IEnumerable<Point> points) { }
  • monadic null checking – if (points?.FirstOrDefault()?.X ?? -1) { }
  • constructor type parameter inference – var t = new Tuple(1,2); // infers Tuple<T1, T2>
  • inline declarations for out params – public void Foo(out var x, out var y) { }

I love all these features perhaps with the exception of the last one. Whist it doesn’t negatively effect the language (although some of the audience were concerned about encouraging the use of out parameters) it doesn’t really do much to achieve the stated goal of improving syntax for multiple return values. I was hoping for something like:

public (int x, int y) Foo() { }

But still, the rest of the features look awesome and I can’t wait to get my hands on C# vNext!

More info at http://adamralph.com/2013/12/06/ndc-diary-day-3/

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s