Tuple literal syntax + Tuple assignment

kenji hara k.hara.pg at gmail.com
Thu Oct 7 10:42:53 PDT 2010


2010年10月8日1:34 Andrei Alexandrescu <SeeWebsiteForEmail at erdani.org>:
> On 10/7/10 11:11 CDT, kenji hara wrote:
>> 2010/10/7 bearophile<bearophileHUGS at lycos.com>:
>>> Another design decision is if tuples have a nominative or structural type, this problem comes out in this bug report:
>>> http://d.puremagic.com/issues/show_bug.cgi?id=4128
>>
>>> Another significant problem is about naming things, currently the situation is a mess:
>>> http://www.digitalmars.com/d/archives/digitalmars/D/Tuple_TypeTuple_tupleof_etc_113005.html
>>> http://d.puremagic.com/issues/show_bug.cgi?id=4113
>>> In the end I have suggested to name "record" the typecons tuples, and "tuple" the typetuples.
>>
>> On these issues, I'm almost agreed with bearophile
>>
>> I think we may not use 'Tuple' as 'a structure packed values'.
>> It is more better that 'Tuple' should *only* use as mixing sequence
>> types and values.
>
> The problem with this is that it departs from nomenclature that is
> agreed by everyone else, which is provincial.
>
> First off, a tuple IS agreed to be an ordered collection of
> heterogeneous items. Google reveals copious evidence, both in math and
> programming language theory.
>
> Benjamin Pierce's "Types and programming languages", a book that all PL
> students sleep with under their pillow, defines tuples in section 11.7
> (entitled "Tuples") like D does. The first paragraph:
>
> "It is easy to generalize the binary products of the previous section to
> n-ary products, often called tuples. For example, {1,2,true} is a
> 3-tuple containing two numbers and a Boolean. Its type is written
> {Nat,Nat,Bool}."
>
> The following section defines records as tuples with labeled fields. I
> don't think it's a crime that D calls both tuples. We could define
> Record just to be more Catholic than the Pope, but I don't see a
> necessity there. At any rate, "Tuple" is correct, known, understood, and
> accepted.

I understood that 'Tuple' is a generic word in math/language theory.
Withdraw my proposals.

> D's built in type tuples (those used with TypeTuple) are weird. They are
> an artifact of the language that has no meaning outside it. Such tuples
> are defined as "anything that could be a template parameter", which
> really ties them to various language design decisions. My suggestion is
> that we deprecate TypeTuple and we call it AliasTuple because that's
> really what it is - it's a tuple of stuff that can be passed in as an
> alias parameter.

It sounds for me that AliasTuple is a limited tuple contains only
alias parameters(exclude types).
I associate three kinds of template parameter (Type, Value, Alias)
with names '{Type|Value|Alias}Tuple'.
So I hope it will be called 'Tuple' in library, too.

(Given these, can I call std.typecons.Tuple ValueTyple?)

Thanks for your answer.

Kenji Hara


More information about the Digitalmars-d mailing list