News for hackers. Stuff that matters.
Re:What’s New in C# 7.0 by daxfohl on Wednesday August 24, 2016 @10:15PM (#12356580)
All I want is easy syntax for immutable records, and C#-like a fluent syntax for .WithPhoneNumber(phoneNumber) etc. Seems like it'd be a cinch to implement, and for me the single handiest feature from F#.

In F# these are "guaranteed" to be non-null, even though null instances come up during deserialization all the time. In C# use cases, I don't think the non-null "guarantee" should be made or implied, just a POCO.

Re:What’s New in C# 7.0 by CyrusNajmabadi on Wednesday August 24, 2016 @10:33PM (#12356639)
Hi there! C# language designer here.

You can see (and participate in) the discussion on records here if you'd like: https://github.com/dotnet/roslyn/issues/10154

> Seems like it'd be a cinch to implement

Ah... how i wish that were so :)

Re:What’s New in C# 7.0 by daxfohl on Wednesday August 24, 2016 @10:57PM (#12356711)
Indeed. While records are my favorite feature from F#, they could be improved.

I'd love it if record definitions were extensible (even abstractly--sometimes you want a record with just the data, and sometimes including db-centric "id, createdTime, etc"), and there should be a way of defining / converting between them without a ton of boilerplate. That would allow something like:

record DbStuff = { id: int; created: DateTime }

record UserRecord: DbStuff { name: string; ... }

var userRecord = new UserRecord(...)

var userData = userRecord.WithoutDbStuff() // but what would be the reflected name of this type?

var newRecord = userData.WithDbStuff(3, DateTime.Now)

----

Sometimes you want to be able to define records

PhotoData{source, metadata, yada, etc, url} and

PhotoDisp{source, metadata, yada, etc, bytes}

without the repetition, and again with an easy way to convert between the two. (And yes you could simplify the above by using containership but oftentimes there are cross-cutting things that containership doesn't solve. You really want a flattening solution.)

Easy integration with C# anonymous classes should be considered too.

C# has always been the more real-world-centric language so I'd hope these common use cases would be considered.

Re:What’s New in C# 7.0 by JamesBarney on Thursday August 25, 2016 @11:34AM (#12359837)
I second this! The ability to easily create intersection types would be awesome!