On Sunday, 26 October 2014 at 19:32:28 UTC, ketmar via Digitalmars-d-learn wrote:
On Sun, 26 Oct 2014 12:46:06 +0000
via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> wrote:

The second possibility doesn't exist right now. The core problem is that the compiler needs to be able to generate runtime code for `buildWriter()`, because it's just a function after all.
but it's templated function, and it's never called in runtime, so
compiler never needs to generate code for it.

The documentation specifically says that:
"Any functions that execute at compile time must also be executable at run time. [...] This means that the semantics of a function cannot depend on compile time values of the function."

http://dlang.org/function.html

I can imagine it would be difficult to implement it differently, because in effect the compiler would need to create a new instance of the function for every call, with each instance potentially being completely different (consider `static if` over CTFE runtime parameters).

Reply via email to