s/type tuple/template pack/g please
Regan Heath
regan at netmail.co.nz
Thu Aug 22 05:00:26 PDT 2013
On Thu, 22 Aug 2013 11:32:06 +0100, dennis luehring <dl.soluz at gmx.net>
wrote:
> Am 22.08.2013 12:05, schrieb Regan Heath:
>> On Wed, 21 Aug 2013 18:53:06 +0100, Andrei Alexandrescu
>> <SeeWebsiteForEmail at erdani.org> wrote:
>>
>>> There's an inordinate amount of confusion around what we currently call
>>> "type tuple" (embodied in std's TypeTuple). I've been furious
>>> immediately as I got word that Walter called it that way, and it hasn't
>>> failed to make everybody else feel the same over the years.
>>>
>>> So: shall we use "template pack" going forward exclusively whenever we
>>> refer to that stuff? That way we can unambiguously use "tuple" for
>>> "value tuples, i.e. like mini-structs that group values together".
>>>
>>> Destroy. I mean criticize.
>>
>> After reading the thread I think it might help to try to define the
>> important characteristics of them, and from that select the key
>>
>> Using this as a reference to my understanding:
>> http://wiki.dlang.org/The_D_Programming_Language/Seq
>>
>> In particular the section:
>> "Q: What's the deal with "auto-expansion"?"
>>
>> I think .. "type tuples" are:
>> - Compile time
>> - A kind of (list, set, group, or collection) of (parameters/arguments,
>> initialisers, parent classes)
>> - Flat i.e. "auto expanded" where used, not nested.
>> - An alias for the elements it contains
>> - A <thing> in which the ordering is important
>>
>> I am leaning toward the fact that they are an "alias" being a key
>> property, that and the fact that they are a "list" or "set" of things.
>> "Sequence" may be even better than list as it imples more heavily that
>> the
>> ordering is important.
>>
>> So, I am personally leaning toward dennis's suggestion of "Alias
>> Sequence".
>>
>> But, I do worry a little about overloading the term "alias". However..
>> TypeTuple is defined using "alias" so maybe they are the "same thing"
>> after all.
>>
>> R
>
> an alias is an real accessible symbol - not just an position in a
> sequence
>
> or am i wrong here?
That's not quite what I was trying to say.
I see it as the Alias Sequence being an alias for the entire sequence of
symbols/expressions in the ordering in which they are given/defined.
That said, to actually use them as aliases you need to name them, with an
"alias" expression, e.g.
// inspired by http://wiki.dlang.org/The_D_Programming_Language/Seq
import std.stdio;
template AliasSeqence(T...){ alias AliasSeqence = T; }
alias one = AliasSeqence!(1);
alias onetwo = AliasSeqence!(one,2);
alias parented = AliasSeqence!(B,C);
alias orphaned = AliasSeqence!();
// Parent list:
interface C { }
class B: orphaned { } // meaning: class B{ }
class A: parented // meaning: class A: B,C{ }
{
this(int a, int b) { writefln("A.a = %d, A.b = %d", a, b); }
}
// Array literal element list:
int[] digits = [0,onetwo,3]; // meaning: [0,1,2,3]
void foo(int a, int b, int c) { writefln("foo(%d,%d,%d)", a, b, c); }
void Foo(int a, int b, int c)() { writefln("Foo(%d,%d,%d)", a, b, c); }
void main()
{
writefln("digits = %s", digits);
// Function argument list (including struct constructor calls, excluding
arguments to overloaded operators):
foo(onetwo,3); // meaning: foo(1,2,3)
// Template argument list (this is why you cannot have argument lists
nested within argument lists).
Foo!(0,onetwo)(); // meaning: Foo!(0,1,2)
// Index argument list:
int[] arr = new int[2];
arr[one] = 2; // meaning: arr[1]
writefln("arr[one]=%d", arr[one]);
// New argument list(s):
A a = new A(onetwo); // meaning new A(1,2)
}
R
--
Using Opera's revolutionary email client: http://www.opera.com/mail/
More information about the Digitalmars-d
mailing list