DIP 1003 Formal Review

via Digitalmars-d digitalmars-d at puremagic.com
Sat May 13 05:51:31 PDT 2017


On Saturday, 13 May 2017 at 10:46:51 UTC, Jonathan M Davis wrote:
> On Saturday, May 13, 2017 08:50:10 via Digitalmars-d wrote:
>> On Friday, 12 May 2017 at 16:17:03 UTC, Mike Parker wrote:
>> > The first stage of the formal review for DIP 1003 [1], 
>> > "Remove body as a Keyword", is now underway. From now until 
>> > 11:59 PM ET on May 26 (3:59 AM GMT on May 27), the community 
>> > has the opportunity to provide last-minute feedback. If you 
>> > missed the preliminary review [2], this is your chance to 
>> > provide input.
>> >
>> > At the end of the feedback period, I will submit the DIP to 
>> > Walter and Andrei for their final decision. Thanks in 
>> > advance to those of you who participate.
>> >
>> > [1] 
>> > https://github.com/dlang/DIPs/blob/fbb797f61ac92300eda1d63202157cd2a30ba 555/DIPs/DIP1003.md
>> >
>> > [2] 
>> > http://forum.dlang.org/thread/qgxvrbxrvkxtimzvnetu@forum.dlang.org
>>
>> I vote for option 4 - a combination of 1 and 3:
>> * Make body a contextual keyword
>> * Allow omitting it
>> * No need for deprecation
>>
>> I don't buy the argument against contextual keywords. D 
>> already has them. For example 'C++' can mean two things 
>> depending on the context:
>>
>> // 1:
>> int C;
>> C++;
>>
>> // 2:
>> extern (C++) void foo();
>
> Except that C++ is not a keyword anymore than linux is a 
> keyword in
>
> version(linux)
>
> It's an identifier (albeit one that doesn't quite follow the 
> normal naming scheme for identifiers).

No, they're not the same. 'something' in 'version (something)' or
'debug (something)' can be either:
1) an integer
2) 'assert' or 'unittest' keyword
3) an identifier.

'debug' and 'version' identifiers live in their own namespaces 
which
is why they don't conflict with other identifiers in the program.
'linux' in the context of 'version (linux)' is 3) - a predefined
version identifier, and like all other identifiers it has to obey
by a certain set of rules [1]. E.g. you can't have 'version 
(C++-interop)'.

Contextual keywords [2] like 'C++', 'Objective-C' or 'exit' on 
the other hand
are not identifiers and that's why don't need to follow [1]. The 
fact that
the spec refuses to call them keywords [3] and they are parsed as
identifiers [4],[5] (but only the 'C' and 'Objective' parts) in 
dmd is
an artifact of an implementation detail. In essence, they behave 
exactly
as contextual keywords in C# [6].
But just for fun, let's say I play you're game. Then why not make 
'body' an
identifier living in it's own namespace, just like 'failure' and 
'exit'? :P

> ... and Walter is completely against adding them, so I'd expect 
> that any proposal that required them would be DOA. And not 
> having them definitely simplifies lexing and parsing D code, so 
> it's quite understandable that Walter is against them.
>

You're just trying to represent Walter's opinion without adding 
new information.

Adding contextual keywords to a language with context free 
grammar won't make
the language grammar context dependent and that's why I don't buy 
the argument
that this would somehow complicate the process parsing D code. 
Yes, it may
require changes to dmd, but in general it's not a difficult 
problem to solve,
as other language implementation demonstrate quite well.

[0]: https://dlang.org/spec/version.html#version
[1]: https://dlang.org/spec/lex.html#Identifier
[2]: See Timon's post for a more complete list: 
http://forum.dlang.org/post/of6n2e$2ne2$1@digitalmars.com
[3]: http://dlang.org/spec/attribute.html#linkage
[4]: 
https://github.com/dlang/dmd/blob/v2.074.0/src/ddmd/parse.d#L2148
[5]: 
https://github.com/dlang/dmd/blob/v2.074.0/src/ddmd/parse.d#L5418
[6]: 
https://docs.microsoft.com/en-us/dotnet/articles/csharp/language-reference/keywords/contextual-keywords


More information about the Digitalmars-d mailing list