DIP 50 - AST macros

Rikki Cattermole alphaglosined at gmail.com
Mon Nov 11 02:28:28 PST 2013


On Monday, 11 November 2013 at 10:19:49 UTC, Jacob Carlborg wrote:
> On 2013-11-11 11:11, Rikki Cattermole wrote:
>
>> For errors I was thinking a new pragma.
>> pragma(error, "You did x wrong");
>> This would fire an error and display the text given. Returning 
>> error
>> code as expected. It is after all in the same league as msg.
>> It would also remove our current static asserts in our code.
>> So other words it could be replicated by:
>>
>> pragma(msg, "You did x wrong");
>> static assert(0);
>>
>> Just without the whole failed assert message.
>
> I like the context parameter better. I'm imagine the context 
> parameter containing a lot of information and functionality to 
> interact with the compiler. A pragma seems not be general 
> enough.

I can understand wanting to have a high level version of it in 
context. I'm just considering a high reuse language feature that 
could back it. Really it should have been added a while ago given 
the static assert trick is used a bit.
I do actually like the idea of having the ability to call it on 
context with a bunch of extra information given to it for you. 
e.g. line number of initiation ext.


More information about the Digitalmars-d mailing list