AST macros

Walter Bright newshound at digitalmars.com
Sat Mar 17 18:58:55 PDT 2007


>> eao197 wrote:
> On naming why not use mixin, since they are so similar?
> 
> mixin print(arg)
> {
> 
> }

I thought it would be too confusing to have 3 different mixin things.


> What if you want the file in some other context?  It would be nice to have a complete solution to that, which allows some sort of stack traversal.  Although I'm not sure its possible, due to not wanting to keep this sort of information around at release time.
> 
> ie:
> 
>      macro print(arg)
>      {
>          writefln(__FILE__[stack_level], __LINE__[stack_level], arg);
>      }
> 
> Or even better:
> 
> Stack[0].Line; //Current line
> Stack[1].Line; //Line one level up
> Stack[0].File;
> Stack[0].Module;
> Stack[0].Function;
> Stack[0].NumbArgs; //Some form of reflection
> Stack[0].Arg[N];   //Access to the value of the argument (ie Turple of values)
> Stack[0].ArgIdentifier[N] //String name of the identifier
> Stack[0].FuncType     //The type of function we are in (is it a macro, a compile time function a member, a regular function)
> ect...

That would be something for much later.



More information about the Digitalmars-d mailing list