Allows the use of part of the language keywords?
ZombineDev via Digitalmars-d
digitalmars-d at puremagic.com
Sat Aug 27 06:36:25 PDT 2016
On Friday, 26 August 2016 at 18:58:25 UTC, Jonathan M Davis 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
As Timon said, this won't make the grammar context dependent.
Also,
C# has the concept of contextual keywords. Such keywords have
special meaning in certain contexts but are otherwise available
for use as identifiers. C# also allows to use normal keywords as
identifiers, but you have use the @for syntax to disambiguate
(e.g. see http://rextester.com/JBOTC21251). From my experience of
using C# the system is well designed and I have never seen
problems in practice. I'm sure something similar can successfully
be implemented for D. Though I would consider such enhancement
with low priority.
See https://msdn.microsoft.com/en-us/library/x53a06bb.aspx for
more info.
More information about the Digitalmars-d
mailing list