Template limits

bearophile bearophileHUGS at lycos.com
Mon May 25 05:21:41 PDT 2009


Max Samukha:
> Your example can be rewritten like this: [...]<

Thank you, it works.
I have tried using result~=m; in a forward-directed for loop, but that didn't work. I think because result=m~result; creates a new array, while result~=m; tries to extend it, failing (even if with result~=m; D1 shows an error message that shows the full correct array anyway, strange).

It seems you have to use subtly functional-style code in compile-time functions too.
I'll use similar solutions in various situations.

------------------

Don:

>It's a bug in D1, actually.  The bug was fixed in D2 but not yet in D1. As you increase the value, D1 will just silently segfault eventually. I believe D1 will be fixed in the next release.<

So I'll be unable to loop a template 1000 times in D1 too?


>It's bug 2569. Nothing fundamental.<

It's not fundamental, but fixed-sized arrays seems a very good fit for compile-time functions. So it deserves an improvement.

Thank you for the code and the explanations,
bye,
bearophile



More information about the Digitalmars-d mailing list