DIP 50 - AST macros

Rikki Cattermole alphaglosined at gmail.com
Mon Nov 11 05:32:06 PST 2013


On Monday, 11 November 2013 at 13:16:23 UTC, Jacob Carlborg wrote:
> I just don't want to add a bunch of pragmas. I don't know 
> what's the best solution.

I am only suggesting one :)
We only need one that'll output any text we want it to and make 
the compiler consider it an error.
On the macro side of things we can build a string which then can 
be given to the pragma.

All of the wrapping giving the goodness would go into the context.

Current what I have enables this:

void main() {
	U u;
}

alias T!("hi", "bye") U;

struct T(string a, string b) {
	pragma(error, a ~ "\n" ~ b);
}

test.d(8): Error: hi
bye

test.d(5): Error: template instance test.T!("hi", "bye") error 
instantiating

Not really in pull state but thats the best I can do. Really that 
final error should be omitted.


More information about the Digitalmars-d mailing list