feature request: __ARGS__ for logging (cf __FILE__, __LINE__, __FUNC___)

Jacob Carlborg doob at me.com
Tue Feb 5 09:08:26 PST 2013


On 2013-02-05 16:24, Timon Gehr wrote:

> I'd prefer if it needn't be.
>
> macro match(Context context, Ast ast, string code){
>      ...
>      if(...) context.error("invalid syntax", code[a..b]);
>      // (slice of code describes exact location where error
>      // is shown to user at the call site.)
>      ...
> }

The whole point of AST macros is that the compiler will do the lexing 
and parsing of the code. It will then just return an AST and it's up to 
the developer of the macro to implement the semantics.

If the code is just passed as a string to the macro you would then need 
to lex and parse in addition to implementing the semantics and we would 
be no better than the current situation with string mixins.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list