On Thu, Apr 23, 2020 at 2:50 AM Steven Schveighoffer via Digitalmars-d <digitalmars-d@puremagic.com> wrote:
On 4/22/20 10:37 AM, Manu wrote:
> I think efficient implementation here would depend on a static fold,
> which I plan for a follow-up, and it's a very trivial expansion from
> this DIP.
> Static reduce would allow `...` as an argument to a BinOp
> Ie; `Tup + ...` would expand `Tup[0] + Tup[1] + Tup[2] + ...`
> You could do `is(FindType == Tup) || ...`, and it would evaluate true if
> FindType exists in Tup, with no junk template instantiations!

This is awesome, and I'm not seeing why you would save it for later.

Because it's strictly additive, DIP's with over-reach tend to fail.

In general, couldn't this DIP be done just strictly on binary operators
and do what this DIP does with commas?

i.e.

foo(T) , ... expands to foo(T[0]), foo(T[1]), ..., foo(T[n])

That looks really grammatically challenging to me. I wouldn't know where to start attempting to implement that :/
The current patch in the compiler is extremely sanitary and self-contained, but I can't imagine how to do that without making some pretty aggressive changes to the parser. I think that's likely to have unexpected and far-reaching side-effects.
It could be expanded to support that syntax in the future, but I'd rather move with the simple definition I have in the DIP today. I think what you describe above is very risky :/