Tuple basics
downs
default_357-line at yahoo.de
Sat Sep 13 08:58:04 PDT 2008
Derek Parnell wrote:
> On Fri, 12 Sep 2008 21:34:25 -0400, Sam Hu wrote:
>
>> Hi,
>>
>> I seached questions regarding Tuple in this newsgroup but did not find the the same question I have.Since I am a newbie ,they are too advanced to me at this moment.My question is just :What is tuple?what can tuple do in D while other languae like c++ can not do or can not do well?Could somebody please post a very simple code segment and an simple but enough explanation so that I can understand what the hell a tuple is .
>
> I think that in D, a tuple is a lexical construct and not a run-time
> construct. This means that it only exists while the application is being
> complied and once compiled a tuple has no run-time representation. It is an
> aid to writing generic code because it allows you to specify a
> list/se/sequence of Types that you can address indivually as if it was an
> array of types. They are Types and not Data values.
A list of anything, actually. Types, compile-time values, expressions, or any mix of the previous.
Tuples of the same kind are the most common though.
(for instance, struct_var.tupleof is a run-time value tuple :)
>
> Of course, I could be totally wrong as I haven't needed to use them yet.
>
More information about the Digitalmars-d-learn
mailing list