4 ms·
Tuples will be native first class citizen on C# 7 (https://blogs.msdn.microsoft.com/dotnet/2016/08/24/whats-new-in-csharp-7-0/ https://blogs.msdn.microsoft.com/
by ZeroClickOk 10y ago
Tuples will be native first class citizen on C# 7 (https://blogs.msdn.microsoft.com/dotnet/2016/08/24/whats-new-in-csharp-7-0/ https://blogs.msdn.microsoft.com/dotnet/2016/08/24/whats-new...)
- hurricaneSlider 10y agoI've been using them quite heavily already. Lovely stuff. Though disappointing that record types didn't make it in.
- dualogy 10y agoDoing Haskell nowadays, been years since touching C# --- maybe my memory is fooling me but didn't have C# "structs" (or whatever they were called) from the very start? What else exactly are "record types" if not those? Or do you simply mean some leaner syntactic sugar for their on-the-fly instantiation?
- hurricaneSlider 10y agoYip syntactic sugar for immutable property only class instantiation. Structs differ from classes in that they are guaranteed to be contiguously placed laid out in memory; they're also non nullable and can't be a part of the inheritance hierarchy (though they can implement interfaces, which have some perf tradeoffs).
- rubber_duck 10y agoStructs are mutable value types. Record types would let you define objects with public getters only and constructor that assigns them and a fancy syntax for creating a new object based on an existing record value + new property values, I think something like Point a = b with {X = 0} this will make using immutable record types in C# much less tedious. Will also implement other stuff like value equality override, etc. I wish this was in 7.0, this is a great way to do FP in C# when you can't use F#. Proposal link : https://github.com/dotnet/roslyn/blob/features/records/docs/features/records.md https://github.com/dotnet/roslyn/blob/features/records/docs/...
- christophilus 10y agoI'm curious how you made that transition,and what problem domain you're in. I predominantly write web applications. Lots of React, but some traditional MVC apps,too. Haskell is a language I want to love, but haven't ever managed to find it productive in my problem space.
- dualogy 10y agoHaven't done it all that long, after C# I first went Go for a few years, and spent much time with GL shaders and such too. Haven't done such "real-world" stuff (with a proper server side, client side, data side etc) in Haskell either --- yet. It's not immediately productivity-inducing at all. I think over the very long haul, prolonged intensive exposure makes many a developer of "mainstream/web/crud/mvp/etc extractions" a much more rigorous, precise, exacting practitioner, which will yield a hard-to-quantify, harder-to-capitalize-on, but still very real and more substantive/deeper/sustained "productivity boost". It also teaches one to think of more robust patterns of abstraction and generalization which can translate back into programming-in-other-languages. Nothing more tangible than that to report. Also there's a lot of curious-researcher-type "playfulness" in the wider ecosystem that's very tricky to assess what this will actually buy the "let's get coding" "brogrammer" (such as I)! One facet that makes it quite worthwhile is that the language/compiler/ecosystem has incredibly bright people contributing not just by devising yet another funky undecipherable combinator for saving 10 lines of code in once-a-decade scenarios, but in fact actual hardcore pedal-to-the-metal under-the-hood optimizations, code check/test/validation assistence tools, keeping it all somewhat performant in server/parallel/concurrent scenarios and so on.
- deleted 10y ago[deleted]
- louthy 10y agoAuthor here. When I started the project C#6 was just arriving. It's awesome to see the ValueTuples coming through for C#7. I have been adding some super-powers to them for lang-ext 2.0 (which is work in progress): Example of extensions for ValueTuple<A,B,C> (there are extensions up to ValueTuple<A,B,C,D,E,F,G> and Tuple<A,B,C,D,E,F,G>) https://github.com/louthy/language-ext/blob/type-classes/LanguageExt.Core/DataTypes/ValueTuple/Tuple3/ValueTuple3.Extensions.cs https://github.com/louthy/language-ext/blob/type-classes/Lan... It allows cool stuff like this: var abc = ('a', 'b').Add('c'); // ('a', 'b', 'c') var abcd = ('a', 'b').Add('c').Add('d'); // ('a', 'b', 'c', 'd') var abcd5 = ('a', 'b').Add('c').Add('d').Add(5); // ('a', 'b', 'c', 'd', 5) var sumA = (1, 2, 3).Sum<TInt, int>(); // 6 var sumB = (2, 4, 8).Product<TInt, int>(); // 64 var flag = ("one", "two", "three").Contains<TString, string>("one"); // true var str = ("Hello", " ", "World").Concat<TString, string>(); // "Hello World" var list = (List(1, 2, 3), List(4, 5, 6)).Concat<TLst<int>, Lst<int>>(); // [1,2,3,4,5,6]