I dun a DIP, possibly the best DIP ever
Q. Schroll
qs.il.paperinik at gmail.com
Fri May 8 20:53:39 UTC 2020
There are some corner cases I'd like to have an answer to:
void f(int i, long l) { }
import std.typecons : Tuple;
alias Tup = Tuple!(int, long);
Tup t = Tup.init;
f(t...); //?
Would that //? line work, i.e. use `alias expand this` of
std.typecons.Tuple? (Currently, without the dots, it doesn't
work!) If so, say I have nested tuple types like these:
alias AB = Tuple!(A, B);
alias CD = Tuple!(C, D);
alias T = Tuple!(AB, CD);
void g(AB ab, CD cd) { }
void h(A a, B b, C c, D d) { }
T t = T.init;
g(t...); //1 t... should be (t.expand[0], t.expand[1])
h(t...); //2
h((t...)...); //3 (t...)... should be
(t.expand[0].expand[0], t.expand[0].expand[1],
t.expand[1].expand[0], t.expand[1].expand[1])
I'd expect //1 to work. Does `...` expand multiple times if it
needs to like in //2 or would I need to do the thing in //3?
Would //3 even work?
I'm asking about stuff that C++ wouldn't need to care about.
What does t.expand... mean? Without much thinking, I'd expect
(t.expand[0], t.expand[1]), but if `...` really walks into the
expression, seeing `.` as a binary operator, it should be
expanding `t` and `expand` in parallel, for `t` using its alias
this. That way, it boils down to (t.expand[0] . expand[0],
t.expand[1] . expand[1]).
Should we be allowed to write (t.expand)... and t.(expand...) to
clarify what we mean?
(I want this DIP to succeed, so I'll walk into every corner and
expose the cases for them to be addressed.)
More information about the Digitalmars-d
mailing list