www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - DIP 1007 - keywords as identifiers with an escape symbol - feedback

reply Basile B. <b2.temp gmx.com> writes:
I know that there is other hot stuffs since a few days but this 
is a really simple DIP, that has no effect on the grammar and no 
effect on the semantic. It was drafted after the announce of DIP 
1003 last week. During a discussion I've proposed to take a 
radically different approach. This approach is DIP 1007.

The DIP: https://github.com/dlang/DIPs/pull/52
The implementation: https://github.com/dlang/dmd/pull/6324

p.s: about DIP methodology it's not clearly explained when & how 
a manager is introduced, apologies if this topic should be opened 
by someone else !
Dec 19 2016
parent reply Stefan Koch <uplink.coder googlemail.com> writes:
On Monday, 19 December 2016 at 08:14:44 UTC, Basile B. wrote:
 I know that there is other hot stuffs since a few days but this 
 is a really simple DIP, that has no effect on the grammar and 
 no effect on the semantic. It was drafted after the announce of 
 DIP 1003 last week. During a discussion I've proposed to take a 
 radically different approach. This approach is DIP 1007.

 The DIP: https://github.com/dlang/DIPs/pull/52
 The implementation: https://github.com/dlang/dmd/pull/6324

 p.s: about DIP methodology it's not clearly explained when & 
 how a manager is introduced, apologies if this topic should be 
 opened by someone else !
If you are prepending # you might as well prepend _
Dec 19 2016
next sibling parent reply default0 <Kevin.Labschek gmx.de> writes:
On Monday, 19 December 2016 at 08:30:07 UTC, Stefan Koch wrote:
 On Monday, 19 December 2016 at 08:14:44 UTC, Basile B. wrote:
 I know that there is other hot stuffs since a few days but 
 this is a really simple DIP, that has no effect on the grammar 
 and no effect on the semantic. It was drafted after the 
 announce of DIP 1003 last week. During a discussion I've 
 proposed to take a radically different approach. This approach 
 is DIP 1007.

 The DIP: https://github.com/dlang/DIPs/pull/52
 The implementation: https://github.com/dlang/dmd/pull/6324

 p.s: about DIP methodology it's not clearly explained when & 
 how a manager is introduced, apologies if this topic should be 
 opened by someone else !
If you are prepending # you might as well prepend _
That doesn't solve the complications this introduces if you want to serialize to/from members with these names, as seen in the Examples section of the DIP.
Dec 19 2016
next sibling parent reply Basile B. <b2.temp gmx.com> writes:
On Monday, 19 December 2016 at 09:58:28 UTC, default0 wrote:
 On Monday, 19 December 2016 at 08:30:07 UTC, Stefan Koch wrote:
 On Monday, 19 December 2016 at 08:14:44 UTC, Basile B. wrote:
 I know that there is other hot stuffs since a few days but 
 this is a really simple DIP, that has no effect on the 
 grammar and no effect on the semantic. It was drafted after 
 the announce of DIP 1003 last week. During a discussion I've 
 proposed to take a radically different approach. This 
 approach is DIP 1007.

 The DIP: https://github.com/dlang/DIPs/pull/52
 The implementation: https://github.com/dlang/dmd/pull/6324

 p.s: about DIP methodology it's not clearly explained when & 
 how a manager is introduced, apologies if this topic should 
 be opened by someone else !
If you are prepending # you might as well prepend _
That doesn't solve the complications this introduces if you want to serialize to/from members with these names, as seen in the Examples section of the DIP.
Yes it does. See my answer to Stefan. In the code you write #delegate, but the identifier is, as known by the compiler, just "delegate". See the unit tests that passed already several times: https://github.com/dlang/dmd/pull/6324/files#diff-60ac3d231ebb78f79477cc2520a37200R19
Dec 19 2016
parent Basile B. <b2.temp gmx.com> writes:
On Monday, 19 December 2016 at 10:28:31 UTC, Basile B. wrote:
 On Monday, 19 December 2016 at 09:58:28 UTC, default0 wrote:
 That doesn't solve the complications this introduces if you 
 want to serialize to/from members with these names, as seen in 
 the Examples section of the DIP.
Yes it does. See my answer to Stefan. In the code you write #delegate, but the identifier is, as known by the compiler, just "delegate". See the unit tests that passed already several times: https://github.com/dlang/dmd/pull/6324/files#diff-60ac3d231ebb78f79477cc2520a37200R19
Actually the second example didn't work. I've updated the DIP and added (and this time tested...) an archaic serialization system that shows more clearly what's the point. It should be quite straightforward to test. The lexer is rarely modified so I doubt there's ever be any conflict when rebasing to master.
Dec 21 2016
prev sibling parent reply Chris Wright <dhasenan gmail.com> writes:
On Mon, 19 Dec 2016 09:58:28 +0000, default0 wrote:
 On Monday, 19 December 2016 at 08:30:07 UTC, Stefan Koch wrote:
 If you are prepending # you might as well prepend _
That doesn't solve the complications this introduces if you want to serialize to/from members with these names, as seen in the Examples section of the DIP.
Sure, but then we could argue that there should be a way to make any sequence of characters an identifier. There are systems that expect serialized field names with hyphens, for instance. Or if I'm writing code to interoperate with a Cherokee system, I might need to produce JSON with a field "ᏗᏍᏚᏗ". (Which is perfectly valid in C# but not in D.) Jsonizer does this the only way you can: you can use an attribute to specify the serialized name for a field. While we're talking about this, this proposal breaks any string mixin that mixes in an identifier detected with reflection. Address that problem and your proposal just allows identifiers to contain a leading #. There are usually ways around using string mixins, but we haven't even proposed starting a deprecation process for them.
Dec 21 2016
next sibling parent reply Basile B. <b2.temp gmx.com> writes:
On Thursday, 22 December 2016 at 04:11:54 UTC, Chris Wright wrote:
 While we're talking about this, this proposal breaks any string 
 mixin that mixes in an identifier detected with reflection.
RIP DIP 1007. It was too simple to be true.
Dec 22 2016
next sibling parent reply Basile B. <b2.temp gmx.com> writes:
On Thursday, 22 December 2016 at 10:11:19 UTC, Basile B. wrote:
 On Thursday, 22 December 2016 at 04:11:54 UTC, Chris Wright 
 wrote:
 While we're talking about this, this proposal breaks any 
 string mixin that mixes in an identifier detected with 
 reflection.
RIP DIP 1007. It was too simple to be true.
I see something to do to continue the DIP SpecialTokenSequence: SpecialTokenSequencePrefix line IntegerLiteral EndOfLine SpecialTokenSequencePrefix line IntegerLiteral Filespec EndOfLine SpecialTokenSequencePrefixes Keyword SpecialTokenSequencePrefix: # SpecialTokenSequencePrefixes: SpecialTokenSequencePrefix SpecialTokenSequencePrefixes Which means that you can use As many # as you want to escape a keyword. Mixins cannot introspect themselves so basically 'pound pound' will always work. And this is still a simple thing that can be done in the lexer.
Dec 22 2016
parent reply Basile B. <b2.temp gmx.com> writes:
On Thursday, 22 December 2016 at 10:35:23 UTC, Basile B. wrote:
 On Thursday, 22 December 2016 at 10:11:19 UTC, Basile B. wrote:
 On Thursday, 22 December 2016 at 04:11:54 UTC, Chris Wright 
 wrote:
 While we're talking about this, this proposal breaks any 
 string mixin that mixes in an identifier detected with 
 reflection.
RIP DIP 1007. It was too simple to be true.
I see something to do to continue the DIP [...] Which means that you can use As many # as you want to escape a keyword. Mixins cannot introspect themselves so basically 'pound pound' will always work. And this is still a simple thing that can be done in the lexer.
no...it's dead, obviously whatever is the amount of #, they'll be removed when the token is patched for the first time. This just doesn't work with mixins. End of story.
Dec 22 2016
next sibling parent Piotrek <piotrek unknownuniverse.net> writes:
On Thursday, 22 December 2016 at 10:47:37 UTC, Basile B. wrote:
 End of story.
This was worth trying anyway. Especially for the "body" keyword. Personally I don't need it anymore, but it is substantial issue for newcomers wanting to use it badly for web/sci dev. This is probably the most controversial keyword. It is a big pain for a pedant person but on the other hand it is really a non-issue among other programming problems. I bet this case will be brought up continuously. So be prepared. It could have been called something like "fbody" or "def". ;) Cheers, Piotrek
Dec 22 2016
prev sibling parent Chris Wright <dhasenan gmail.com> writes:
On Thu, 22 Dec 2016 10:47:37 +0000, Basile B. wrote:
 no...it's dead, obviously whatever is the amount of #, they'll be
 removed when the token is patched for the first time. This just doesn't
 work with mixins. End of story.
If it's changed to `# identifier` instead of `# keyword`, you can defensively add an octothorp to any identifier you mix in. However, that would fail if someone has an identifier named `line`. And in any case it breaks existing string mixins.
Dec 22 2016
prev sibling parent Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 12/22/2016 05:11 AM, Basile B. wrote:
 On Thursday, 22 December 2016 at 04:11:54 UTC, Chris Wright wrote:
 While we're talking about this, this proposal breaks any string mixin
 that mixes in an identifier detected with reflection.
RIP DIP 1007. It was too simple to be true.
If that's the case please mark it as "Retired". -- Andrei
Dec 22 2016
prev sibling parent Basile B. <b2.temp gmx.com> writes:
On Thursday, 22 December 2016 at 04:11:54 UTC, Chris Wright wrote:
 While we're talking about this, this proposal breaks any string 
 mixin that mixes in an identifier detected with reflection.
http://imgur.com/NHe6k2p
Dec 22 2016
prev sibling parent reply Basile B. <b2.temp gmx.com> writes:
On Monday, 19 December 2016 at 08:30:07 UTC, Stefan Koch wrote:
 On Monday, 19 December 2016 at 08:14:44 UTC, Basile B. wrote:
 I know that there is other hot stuffs since a few days but 
 this is a really simple DIP, that has no effect on the grammar 
 and no effect on the semantic. It was drafted after the 
 announce of DIP 1003 last week. During a discussion I've 
 proposed to take a radically different approach. This approach 
 is DIP 1007.

 The DIP: https://github.com/dlang/DIPs/pull/52
 The implementation: https://github.com/dlang/dmd/pull/6324

 p.s: about DIP methodology it's not clearly explained when & 
 how a manager is introduced, apologies if this topic should be 
 opened by someone else !
If you are prepending # you might as well prepend _
No, because # is not an identifier char while _ is. * _delegate is 1 token (_delegate) * #delegate is 2 tokens ( # then delegate) Then you can determine that the intention is to have "delegate" as identifier, while with _ you cant.
Dec 19 2016
parent Basile B. <b2.temp gmx.com> writes:
On Monday, 19 December 2016 at 10:24:08 UTC, Basile B. wrote:
 On Monday, 19 December 2016 at 08:30:07 UTC, Stefan Koch wrote:
 If you are prepending # you might as well prepend _
No, because # is not an identifier char while _ is. * _delegate is 1 token (_delegate) * #delegate is 2 tokens ( # then delegate) Then you can determine that the intention is to have "delegate" as identifier, while with _ you cant.
issue for the form of the DIP: "must explain what is an identifier character and what is not". I'm a bit surprised that the two first comments are related to this but anyway, I'll add that # is a symbol and _ an identifier char. I must be be biased by the work on CE highlighter.
Dec 19 2016