3 ms·
> They provide a ton more context for the next reader about what this thing actually is. Right until there’s no more context than “this returns 2 elements” and
by masklinn 4y ago
> They provide a ton more context for the next reader about what this thing actually is.
Right until there’s no more context than “this returns 2 elements” and you end up with 15 different Pair types and more verbosity for no value.
Named tuples are not better than tuples, they’re complementary, both are useful tools.
- vips7L 4y agoThere's definitely always more context than "this returns 2 elements". What are they? What are you storing them in? What did they belong to?
- masklinn 4y ago> There's definitely always more context than "this returns 2 elements". Not usefully so. If you’re splitting a collection in two, whatever context you add is almost certainly worthless overhead not worth the extra type.
- titzer 4y agoI'm trying to let programmers make the call here, which is why Virgil gives you both options. In causal hacking, anonymous tuples can be very useful. I find that very true in test code, where I have a tendency to throw more bells and whistles at it to get meat of the tests really short (so I can write a lot of them). Requiring elaborate ceremonies (such defining a bunch of tuple types for no good reason) is just a waste of time.