CTFE vs. traditional metaprogramming

language_fan foo at bar.com.invalid
Sat Oct 10 14:00:06 PDT 2009


Fri, 09 Oct 2009 16:49:19 -0400, Jarrett Billingsley thusly wrote:

> Where CTFE wins at metaprogramming:
> 
> Liiiiiiiiiiists. If you have a list of something, it's far easier to
> deal with in an imperative CTFE function than in an awkwardly recursive
> template. Edge cases (first, last items) are also easier to deal with
> imperatively.

Of course the "lists" become more efficient and easier to use inside CTFE 
functions since D does not even have built-in lists but arrays. Calling 
Head!(foo) and Head!(Reverse!(foo)) is not that hard in template code, 
but D just does not have a standard template utility function library.

> DSLs, and more generally, parsing. Doing DSL parsing with templates is
> possible but not fun. You end up with a ton of templates. Not that I'm
> advocating parsing lots of things with CTFE either.. you already know
> how I feel about that.

You liek it?



More information about the Digitalmars-d mailing list