On Sun, 26 Oct 2014 20:16:18 +0000
via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> wrote:

> 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).
leaving away technical complexities for compiler writers, i like to say
that restrictions for templated functions can be relaxed. maybe by
marking some templates/functions as "CTFE-only". or just fix semantic
analyser to allow some more things in CTFE. such template will never
instantiates successfully for run-time code, and it still can be used
in metaprogramming.

writing purely functional templates really sux. i made a simple
writef-like module which parses it's format string in compile time and
i must admit that some templates has 10+ arguments and keep growing as
i adding features. either this, or even more convoluted hacks.

alas, i'm still don't understand compiler code deep enough to see how
hard this will be to implement.

Attachment: signature.asc
Description: PGP signature

Reply via email to