On Thursday, 12 June 2014 at 12:31:09 UTC, Dicebot wrote:
On Thursday, 12 June 2014 at 10:40:56 UTC, Colin wrote:
Maybe a change to the compiler to write any mixin'd string out
to a temporary file (along with some identifier information
and the line of code that generated it) and at the next
compilation time try reading it back from that file iff the
line of code that generated it hasnt changed?
Then, there'd be no heavy work for the compiler to do, apart
from read that file in to a string.
Compiler can cache return value of function that get called
from inside mixin statement (for a given argument set). As CTFE
is implicitly pure (no global state at compile-time) later
generated code can be simply re-used for same argument set.
Re-using it between compiler invocations is more tricky because
it is only legal if generator function and all stuff they
indirectly use have not changed too. Ignoring this requirement
can result in nasty build issues that are only fixed by clean
build. Too harmful in my opinion.
Yeah, it quite dangerous I agree. I was only thinking of a
solution to the problem above where a ctRegex is compiled every
time, whether it was changed or not.
I'm sure theres some way of keeping track of all dependent D
modules filename, and if any of them have been changed in the
chain, recalculate the string mixin.
Only trouble with that is, there'd be a good chunk of checking
for every mixin, and would slow the compiler down in normal use