www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Re: Will macros just be syntactic sugar? [EXAMPLE]

reply Dan <murpsoft hotmail.com> writes:
Davidl Wrote:

 Nice work!
 The compiler now is damned powerful :)
 
 Though I still prefer less string operation in compile time, any idea of  
 improving the
 macro syntax I posted? You see, D is going to bring AST macro in future  
 releases. Let's
 discuss the syntax it will use?
The AST Reflection is IMHO a concept capable of becoming powerful enough to rival mixins, and without "compile time text processing"; apart from the compiler processing the source code. : p AST Reflection is basically an API that would allow you to define/access any D statement or expression as if it were a library. I honestly don't know what it ought to look like... AST.identifiers.Foo <-- gives you a Foo AST.statements.If <-- capitalized so you don't use a keyword? AST.identifiers.add(int[][3]*,x) <-- adds a variable AST.identifiers.x.static = true <-- makes x static? Just my thoughts. While this sort of thing at first appears verbose and trivial, it ultimately lets you do really cool stuff with it?
Apr 25 2007
parent Davidl <Davidl 126.com> writes:
AST.identifiers.add(int[][3]*,x) <--- this would be required to be done =
b4
semantic pass.
AST.identifiers.x.static =3D true <-- while this need to be done after  =

semantic
pass.

Also the AST you suggested would make user some what not easy  =

understandable
code, and increase compiling time.

 Davidl Wrote:

 Nice work!
 The compiler now is damned powerful :)

 Though I still prefer less string operation in compile time, any idea=
of
 improving the
 macro syntax I posted? You see, D is going to bring AST macro in futu=
re
 releases. Let's
 discuss the syntax it will use?
The AST Reflection is IMHO a concept capable of becoming powerful enou=
gh =
 to rival mixins, and without "compile time text processing"; apart fro=
m =
 the compiler processing the source code.  : p

 AST Reflection is basically an API that would allow you to define/acce=
ss =
 any D statement or expression as if it were a library.  I honestly don=
't =
 know what it ought to look like...

 AST.identifiers.Foo <-- gives you a Foo
 AST.statements.If <-- capitalized so you don't use a keyword?
 AST.identifiers.add(int[][3]*,x) <-- adds a variable
 AST.identifiers.x.static =3D true <-- makes x static?

 Just my thoughts.  While this sort of thing at first appears verbose a=
nd =
 trivial, it ultimately lets you do really cool stuff with it?
Apr 25 2007