I dun a DIP, possibly the best DIP ever
Manu
turkeyman at gmail.com
Thu Apr 23 13:53:03 UTC 2020
On Thu, Apr 23, 2020 at 10:45 PM Simen Kjærås via Digitalmars-d <
digitalmars-d at puremagic.com> wrote:
> On Wednesday, 22 April 2020 at 12:04:30 UTC, Manu wrote:
> > This DIP single-handedly fixes compile-time issues in programs
> > I've written by reducing template instantiations by near-100%,
> > in particular, the expensive ones; recursive instantiations,
> > usually implementing some form of static map.
> >
> > We should have done this a long time ago.
>
> This is beautiful and awesome (syntax and all).
>
> I was wondering if there's any way to to do a cross product with
> this, like fun(Xs, Ys)... expand to fun(Xs[0], Ys[0]), fun(Xs[0],
> Ys[1]), fun(Xs[1], Ys[0]), fun(Xs[1], Ys[1]), but that might very
> well be rare enough to not warrant special consideration.
>
You can do this by expanding tuples with the appropriate indices:
fun(Xs[CrossIndexX], Ys[CrossIndexY])...
Where CrossIndexX is (0, 0, 1, 1) and CrossIndexY is (0, 1, 0, 1).
The other thing that worries me a little is the difference
> between Foo!(AliasSeq!(1,2))... and Foo!(Numbers)... - would
> Foo!(AliasSeq!(1,2)...)... do the same as Foo!(Numbers)...?
>
This needs to be clarified in the DIP; the AliasSeq!() instantiation there
is NOT actually a tuple (yet). It's just a template instantiation
expression.
So, Foo!(AliasSeq!(1,2)...)... does nothing; there's no tuple in the
expression to expand.
If you want to expand that AliasSeq, you need the second expression you
wrote:
alias Numbers = AliasSeq!(1,2);
Foo!(Numbers)...
So the answer is no, they are not the same.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20200423/22194d72/attachment-0001.htm>
More information about the Digitalmars-d
mailing list