On 8/10/11 11:09 AM, Marco Leise wrote:
With the recent ORM and RegEx projects dissecting SQL statements and
regular expressions turning them into D code, I am impressed by the
possibilities of CTFE. Where are the limitations to this system? An
unlikely example would be a C compiler within CTFE that takes a string
of C source code and turns it into a D mixin. Is that possible?
Yah, that would be possible (albeit difficult). I think, however, that
better applications of CTFE are not for translating full-blown languages
into D. Instead, the best added value would be to translate small DSLs
into D code. Examples include:
* regex (I'm very glad Dmitry found the time to implement that - static
regexen will long serve as a poster child of CTFE's power);
* SQL - embedded SQL integrated perfectly with D data would be awesome
and relatively easy to define;
* Tokenizers (think lex);
* Parsers (think yacc, antlr etc);
* String interpolation (think Python's format, printf-style format
parsed statically etc);
* Make :o);
* Protocol description;
* Automata, transducers of various kinds;
* and more.
I hope Dmitry's work will mark a growing trend of defining DSLs in D.
Andrei