Keywords: How to trick the compiler?

Marc Schütz" <schuetzm at gmx.net> Marc Schütz" <schuetzm at gmx.net>
Sat Feb 1 12:35:38 PST 2014


On Tuesday, 28 January 2014 at 22:50:27 UTC, Stanislav Blinov 
wrote:
> On Tuesday, 28 January 2014 at 22:35:31 UTC, Martin Cejp wrote:
>
>>>> I really wonder whether the rule could be relaxed a little 
>>>> bit.
>>>
>>> o_O How?
>>
>> Not being a keyword except in places where it is used as such.
>
> Only if it's not a keyword at all, lest you complicate parsing. 
> You wouldn't want any other keyword (I dunno, int?) get a 
> special treatment now, would you?
>
> Don't get me wrong, I'm all for allowing to use "body" as an 
> identifier in user code, I just don't see any half-measures in 
> that regard :)

It's surprisingly easy to implement, see here:
https://github.com/schuetzm/dmd/commit/955be4ef9f26e92f7a0d5dedf86b64a03d903be8

It requires only a few trivial changes to the compiler, but I have
to admit that it makes the code uglier. In particular, it doesn't
scale; every keyword treated in this way requires additional
special handling.

I'm not sure whether I should make a PR from this...


More information about the Digitalmars-d-learn mailing list