Jump to page: 1 2 3
Thread overview
Allows the use of part of the language keywords?
Aug 26, 2016
Brian
Aug 26, 2016
Cauterite
Aug 26, 2016
Jonathan M Davis
Aug 26, 2016
Ali Çehreli
Aug 27, 2016
Timon Gehr
Aug 27, 2016
Walter Bright
Aug 27, 2016
Meta
Aug 28, 2016
ketmar
Aug 28, 2016
Basile B.
Aug 28, 2016
Chris Wright
Aug 28, 2016
ketmar
Aug 28, 2016
Cauterite
Aug 28, 2016
Basile B.
Aug 28, 2016
ketmar
Aug 28, 2016
Chris Wright
Aug 28, 2016
ketmar
Aug 28, 2016
Cauterite
Aug 28, 2016
Walter Bright
Aug 27, 2016
ZombineDev
Aug 27, 2016
Walter Bright
Aug 27, 2016
Basile B.
Aug 27, 2016
Mike Parker
August 26, 2016
Allows the use of part of the language keywords, example:

```D
package application.module.user.model;

class User
{
    // TODO
}
```

[code]
sturct module
{
    // TODO
}
[code]

PS: editor don't support markdown or bbcode?- -
August 26, 2016
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.
August 26, 2016
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

August 26, 2016
On 08/26/2016 11:58 AM, 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
>

My understanding is completely different: The OP is looking for code highlight support on the forum. :D (Which actually is a newsgroup but I think the forum does support highlighting.)

Ali

August 27, 2016
On Friday, 26 August 2016 at 14:16:27 UTC, Brian wrote:
> Allows the use of part of the language keywords, example:
> [code]
> sturct module
> {
>     // TODO
> }
> [code]

The D style as used in phobos says that you must add a "_" at the end of the keyword that you wish to use as identifier.

When the problem happens because of linkage to an object or to a static library there's the pragma(mangle):

https://dlang.org/spec/pragma.html#mangle

> PS: editor don't support markdown or bbcode?- -

No, but people use several tricks to denote a code block: github style block code, html tags etc. This times I use °°°°°°°°°°°°°°°°°°


August 27, 2016
On Friday, 26 August 2016 at 14:16:27 UTC, Brian wrote:

>
> PS: editor don't support markdown or bbcode?- -

See this:

http://dlang.org/blog/2016/06/10/core-team-update-vladimir-panteleev/
August 27, 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.
August 27, 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.
August 27, 2016
On 8/27/2016 6:01 AM, Timon Gehr wrote:
> then not-entirely-trivial disambiguation has to be added to the parser. There's
> no ambiguity for the example in the OP though.

It also:

1. mucks with the usability of syntax highlighting, which is often based merely on tokens.
2. makes it potentially much more difficult to add features to the language, which is often done by finding new uses for the same keywords
3. is just plain confusing to the person learning the language
4. makes correctly diagnosing syntactic errors harder

There are a million words in the english language. Having a handful of reserved words should not be a burden.
August 27, 2016
On 8/27/2016 6:36 AM, ZombineDev wrote:
> 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.

D has contextual keywords, too, and has had them since the beginning:

   extern (C)
   pragma (msg, ...)
   scope (exit)

etc.

Microsoft has tried to patent contextual keywords in C#, but I don't think they have a case.
« First   ‹ Prev
1 2 3