Hacker News new | past | comments | ask | show | jobs | submit login

I believe c# has had tuple support since .net framework v4.



I believe tuple support in v4 is a simple set of classes. There is no language construct specific for the use of tuples, which means it's just a library instead of a programming language feature.


What are the advantages that language-level tuples would have over the existing System.Tuple class?


Without deconstruction and pattern matching, language level tuples would be only sugar: "var x = (1, 2)" versus "var x = Tuple.Create(1,2)"

The real power of Tuples only comes with deconstruction and matching, such as "var (a,b) = GetSomething()" and "case (_, y)".

So these features would go hand in hand. Deconstruction and matching requires lang level tuples, and lang level tuples are pretty lame without deconstruction and pattern matching.


The ability to write (2, "hello") instead of Tuple.Create(2, "Hello"). But more importantly, syntax for deconstructing tuples will make tuples convenient for returning multiple values from a method. Eg.: (var x, var y) = getPoint(); as shown in the aticle.


Also, the type is simpler to represent. Instead of Tuple<int, string> you just have something like (Int, String).




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: