On 11/11/2013 12:06 PM, deadalnix wrote:
On Monday, 11 November 2013 at 19:23:21 UTC, Ellery Newcomer wrote:
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

$ refers to the enclosing scope. so $$foo should refers to $foo in the
enclosing scope. No need for special rule or label.

so if I have to splice my ast N times, then I have to generate M $'s depending on when I want it to expand?

Reply via email to