DIP 50 - AST macros
Jacob Carlborg
doob at me.com
Wed Nov 13 00:40:13 PST 2013
On 2013-11-12 21:55, Dmitry Olshansky wrote:
> Actually I couldn't shake off the feeling that macros are just CTFE
> functions on Ast objects. How objects are created and converted back to
> source code is a separate question.
Yes, and reflection.
> If we just had:
>
> //this would invoke compiler's parser at CTFE
> auto ast = "x = y;".astof
>
> and have it work at CTFE to return sensible AST (a big if btw).
>
> And then (after some manipulations):
> ast.toString() //get back a string of D code
>
> It may help code generation of D --> DSL.
>
> Alternatively one can implement D parser that works at CTFE and watch it
> crawl :)
You would still need to do strign mixin. Which results in a some
unnecessary conversion between AST's and strings. See the list at the
bottom of:
http://forum.dlang.org/thread/l5otb1$1dhi$1@digitalmars.com?page=13#post-l5vcct:242lit:241:40digitalmars.com
It also looks ugly.
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list