DIP 50 - AST macros

Jacob Carlborg doob at me.com
Mon Nov 11 05:36:13 PST 2013


On 2013-11-11 14:32, Rikki Cattermole wrote:

> I am only suggesting one :)

What about warnings? And no, the current pragma(msg) isn't the same.

> 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.

I wouldn't say no to this if macros are completely off the table. 
Perhaps it's a good addition regardless.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list