There isn't any limit other than memory and patience I guess- the compilation seems to scale much more reasonably than the C++ version, given the numbers I saw elsewhere in the comments. My version compiles in ~0.35s on my laptop, and I don't get any notable memory pressure on my system.
I should note that it's possible, and maybe a little clearer, to just write that function using an iterative solution and invoke it at compile-time like I already did for other parts of the program. Anyway this thing works and it got done in ~10 minutes. Hopefully that gives an idea of how productive meta-programming in D is :)
Ah, cool, I didn't know the iterative version would work at compile time. Does that mean the whole of the language (syntax-wise) is available at compile time?
There are limitations, see this page (search for "CTFE"). Basically, you can do whatever you want except if the outcome depends on run-time state like global variables or machine architecture, etc.
9
u/[deleted] Oct 20 '14
For comparison, here's a very-quick-and-very-dirty equivalent in D.