Allows the use of part of the language keywords?

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Sat Aug 27 06:01:26 PDT 2016


On 26.08.2016 20:58, Jonathan M Davis via Digitalmars-d wrote:
> On Friday, August 26, 2016 17:59:39 Cauterite via Digitalmars-d wrote:
>> On Friday, 26 August 2016 at 14:16:27 UTC, Brian wrote:
>>> package application.module.user.model;
>>
>> I get "Error: identifier expected following '.' instead of
>> 'module'"
>> So I'm not sure how that compiles for you.
>
> I think that he's looking for a language change that would allow you to use
> keywords in contexts where the keyword would not be valid. It's been
> suggested before, but it was rejected. If nothing else, it doesn't at all
> play nicely with how lexers and parsers normally work. It's _far_ cleaner if
> the compiler can treat a keyword as a keyword in all contexts that it's
> used. Not doing so makes the grammar context-dependent, whereas Walter has
> gone to great lengths to make it completely context-free.
>
> - Jonathan M Davis
>

No, this would not introduce any context-dependence.

https://en.wikipedia.org/wiki/Context-free_grammar

That doesn't mean it is necessarily a great idea though.
It increases ambiguity of the grammar, and hence, if you want to be able 
to parse things like

auto enum = 3;
enum +=2;

then not-entirely-trivial disambiguation has to be added to the parser. 
There's no ambiguity for the example in the OP though.


More information about the Digitalmars-d mailing list