CTFE vs. traditional metaprogramming
Don
nospam at nospam.com
Mon Oct 12 04:26:13 PDT 2009
language_fan wrote:
> Sat, 10 Oct 2009 10:26:11 +0200, Don thusly wrote:
>
>> CTFE doesn't mean "string mixins using CTFE". It just means CTFE. (BTW
>> you can do string mixins with templates only, no CTFE, if you are
>> completely insane).
>
> CTFE without mixins is rather limited form of metaprogramming. You can
> basically only initialize some static non-code data, and not much more.
That's a lot, though. For example, you can perform the compilation step
for a regexp, and determine whether it needs to be implemented with
backtracking, or not. CTFE is perfect for parsing DSLs.
> String mixins with templates was the only way to go before CTFE became
> possible -- those were the times!
They were very short times <g>. String mixins were introduced in
DMDD1.005, (5 Feb 2007) and CTFE came in 1.006, ten days later.
But that was indeed a very fun time for D.
I did a lot of early metaprogramming work with template value
parameters, before string mixins. It was quite ugly, and painful to
write. D metaprogramming techniques have gradually got less hacky over time.
More information about the Digitalmars-d
mailing list