"with" still sucks + removing features + adding features

Jarrett Billingsley jarrett.billingsley at gmail.com
Mon May 18 12:51:31 PDT 2009


On Mon, May 18, 2009 at 3:29 PM, Robert Fraser
<fraserofthenight at gmail.com> wrote:
> Jarrett Billingsley wrote:
>>
>> it'd be an alternative to CTFE (shudder)
>
> Why shudder? CTFE has familiar syntax (the syntax of the runtime language)
> and, I've found, less bugs in general.

It's extremely difficult to make CTFE functions that work.  The
compiler often coughs on seemingly-legal code, sometimes due to bugs.
The biggest issue with developing CTFE functions is that if something
does go wrong during CTFE, all you get is a message along the lines of
"function X can't be evaluated at compile time", with no indication as
to _why_ it couldn't, no stack trace etc.  There's also no means of
outputting debugging statements during CTFE.  At least with templates
I have pragma(msg).

CTFE is also mainly useful for building up string mixins, but since
everything inside a CTFE function has to be code that can be executed
at runtime as well, you forgo some really useful metaprogramming
features that are native to templates, like pattern matching.  So it
ends up being convenient in simple cases (i.e. given a list of names,
generate a bunch of almost-identical declarations for them), but not
in more complex ones.

Not to mention it's much slower than template instantiation and eats
memory for lunch.



More information about the Digitalmars-d mailing list