DIP 50 - AST macros
Ellery Newcomer
ellery-newcomer at utulsa.edu
Mon Nov 11 11:23:20 PST 2013
On 11/10/2013 01:20 PM, Jacob Carlborg wrote:
> I've been thinking quite long of how AST macros could look like in D.
> I've been posting my vision of AST macros here in the newsgroup a couple
> of times already. I've now been asked to create a DIP out of it, so here
> it is:
>
> http://wiki.dlang.org/DIP50
>
For macros that generate macros, I think you need a way to escape the
splicing and maybe define how splicing works in an inner quasi quote.
I guess you want <[ <[ $exp ]> ]> to turn into the ast <[ 1 ]>
Then if you wanted ast <[ <[ $exp ]> ]> with the splice associated with
the inner quasi quote, you'd have to do something like
<[ <[ <[ \\\$exp ]> ]> ]>
maybe a way to associate a splice with a quasi quote?
<a[ <b[ <c[ $(a, exp) + $(b, exp) + $(c, exp) ]> ]> ]>
a's exp is A
b's exp is B
c's exp is C
then splice the quasi quote N times:
1: ast <b[ <c[ A + $(b, exp) + $(c, exp) ]> ]>
2: ast <c[ A + B + $(c, exp) ]>
3: ast A + B + C
just dinking around here
More information about the Digitalmars-d
mailing list