I have certainly been confused by the term 'tuple' used in D countless times. It seems to exist in a variety of different contexts, and every time I think I understood it, I realise I'm probably wrong some time later. There seems to be poor/no documentation comparing/distinguishing various D tuples, also, there seems to be no real explicit syntax, which makes it hard to recognise. I can kinda handle a Tuple template, and then there are these type tuples, and then expression tuples? What is the relationship between these? Are they compatible? How do I distinguish them?
Someone that understand what they're talking about should take some time to write a comprehensive article on the matter :) Some of the things I have read seem to presume that I already know what it's talking about, and as a result, lead to dismissing or misunderstanding the article. I think the practical take-away from my experience is that it ends up as one of those 'too hard' concepts, that I develop a tendency to actively avoid dealing with because it's confused me a number of times. I typically just start typing stuff and hope it works. And if it doesn't I fiddle with it until it eventually does (or I give up), and I never *really* understand why. I'll bet I'm not the only one... On 27 May 2013 10:25, Jonathan M Davis <[email protected]> wrote: > On Sunday, May 26, 2013 22:38:24 Diggory wrote: > > On Sunday, 26 May 2013 at 15:48:00 UTC, Russel Winder wrote: > > > I wonder if people coming to D, looking for information about > > > tuples, > > > will get confused by http://dlang.org/tuple.html which seems to > > > tell > > > people they have to "roll their own", and > > > http://dlang.org/phobos/std_typecons.html which tells people > > > they have > > > been pre-rolled in the standard library? > > > > I found this especially confusing because the built-in Tuple is > > defined differently. > > > > The Tuple in that example is equivalent to the definition of > > TypeTuple, and yet TypeTuple is supposedly specific to types > > while that example (as so by implication TypeTuple) apparently > > works just as well with other contents. > > > > On top of that Tuple is the one that only works with types - any > > string expressions are extracted and used as names... Surely a > > tuple which can only store types should be a TypeTyple and a > > tuple which can store anything should be a Tuple. > > I really wish that the term tuple didn't get used with the built-in tuples > / > TypeTuples. They _aren't_ tuples. They're similar, but they don't nest, and > they cause a lot of confusion with std.typecons.Tuple. And they're only > compile-time constructs to boot. > > - Jonathan M Davis >
