4 ms·
There have been Generic Tuples for a while in .NET... https://msdn.microsoft.com/en-us/library/system.tuple%28v=vs.110%29.aspx https://msdn.microsoft.com/en-us/
by NKCSS 11y ago
There have been Generic Tuples for a while in .NET... https://msdn.microsoft.com/en-us/library/system.tuple%28v=vs.110%29.aspx https://msdn.microsoft.com/en-us/library/system.tuple%28v=vs...
- mattmanser 11y agoThose things suck. Every time I think about using them I always end up just using a dict or declaring a new struct.
- MichaelGG 11y agoF# uses them just fine and they don't suck. So perhaps it's just the compiler/language not dealing with them very well? Edit: OK so it does suck that it's a reference type for even small tuples. But it's not C#/F#'s fault the CLR doesn't do a better job on those kinda things.
- Guvante 11y agoF# allows you to break up the tuple immediately, this tremendously aids readability as it avoids introducing confusing names. let (a, b) = Foo() Compared to var tuple = Foo(); var a = tuple.Item1; var b = tuple.Item2; You could consider them equivalent, but conceptually it is faster to understand that a is the first result IMO.
- MichaelGG 11y agoI'm just pointing out that System.Tuple doesn't suck as the commenter was saying. It's just C#'s handling of them.
- mattmanser 11y agoWhich means they suck in C# doesn't it?
- Guvante 11y agoGiven that the proposal specifically mentions using struct instead of class it isn't just C#'s handling that makes it difficult to leverage System.Tuple.
- MichaelGG 11y agoFunny, the BCL folks went with a class and we were assured it was a good decision. Maybe they just need to get their JIT up to date and do escape analysis so this kinda thing doesn't cost so much. (Easy for me to say they should do it...) After using Rust+LLVM I'm accustomed to the idea of not having to pay so much for features.
- mhomde 11y agoYeah I agree, having to keep in mind what you put into Item1, Item2, Item3 etc really isn't programmer friendly