Thread overview | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
March 27, 2015 Advise for syntax highlighting | ||||
---|---|---|---|---|
| ||||
I'm currently updating the TextMate D bundle for D2. I have a couple of questions for how to highlighting some specific code or how other editors/IDE's highlight them.
* "this" in constructor
this () {}
In TextMate functions/methods are highlighted, should this be highlighted as a keyword or as a method?
* "this" in copy constructor
this (this) {}
The "this" parameter, should that be highlighted as a keyword or as a parameter?
* The "__ctfe" variable
if (__ctfe) {}
How should this highlighted? I see a couple of alternatives:
- not at all
- as a keyword
- as a special recognized built-in symbol, similar to __LINE__
- as a special recognized library symbol. For example, in the C bundle many of functions in the standard library are specially recognized and highlighted differently. This might not apply here since it's not a library symbol
* __traits identifiers
__traits(allMembers, Foo);
In this case "allMembers". Basically the same question and alternatives as for the "__ctfe" variable.
* Predefined version identifiers
version (OSX) {}
Again, same a question and alternatives as for the "__ctfe" variable.
* Extern identifiers
extern (C)
Again, same a question and alternatives as for the "__ctfe" variable.
--
/Jacob Carlborg
|
March 27, 2015 Re: Advise for syntax highlighting | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | On Friday, 27 March 2015 at 10:34:58 UTC, Jacob Carlborg wrote:
> I'm currently updating the TextMate D bundle for D2. I have a couple of questions for how to highlighting some specific code or how other editors/IDE's highlight them.
>
> * "this" in constructor
>
> this () {}
>
> In TextMate functions/methods are highlighted, should this be highlighted as a keyword or as a method?
>
> * "this" in copy constructor
>
> this (this) {}
>
> The "this" parameter, should that be highlighted as a keyword or as a parameter?
>
> * The "__ctfe" variable
>
> if (__ctfe) {}
>
> How should this highlighted? I see a couple of alternatives:
>
> - not at all
> - as a keyword
> - as a special recognized built-in symbol, similar to __LINE__
> - as a special recognized library symbol. For example, in the C bundle many of functions in the standard library are specially recognized and highlighted differently. This might not apply here since it's not a library symbol
>
> * __traits identifiers
>
> __traits(allMembers, Foo);
>
> In this case "allMembers". Basically the same question and alternatives as for the "__ctfe" variable.
>
> * Predefined version identifiers
>
> version (OSX) {}
>
> Again, same a question and alternatives as for the "__ctfe" variable.
>
> * Extern identifiers
>
> extern (C)
>
> Again, same a question and alternatives as for the "__ctfe" variable.
Am using Textadept, the highlighting is as follows:
highlighted as keyword:
this()
__traits
extern(C) // The "extern"; "C" isn't highlighted at all
highlighted as a special recognized built-in symbol, similar to __LINE__:
version(OSX) // the OSX; "version" is highlighted as keyword
not highlighted at all:
__ctfe
|
March 27, 2015 Re: Advise for syntax highlighting | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chris | On 2015-03-27 13:33, Chris wrote: > Am using Textadept, the highlighting is as follows: > > highlighted as keyword: > this() Why is this highlighted as a keyword? I was more leaning to highlight it as a method. What about the parameter in a copy constructor? > __traits What about the identifiers/keywords used as the first argument to "__traits"? -- /Jacob Carlborg |
March 27, 2015 Re: Advise for syntax highlighting | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | On Friday, 27 March 2015 at 13:58:03 UTC, Jacob Carlborg wrote: > On 2015-03-27 13:33, Chris wrote: > >> Am using Textadept, the highlighting is as follows: >> >> highlighted as keyword: >> this() > > Why is this highlighted as a keyword? I was more leaning to highlight it as a method. Well, it _is_ a keyword. You cannot write a function called "this", nor can you use it as a variable name. So yes, it's a keyword = reserved. > What about the parameter in a copy constructor? > >> __traits > > What about the identifiers/keywords used as the first argument to "__traits"? Not highlighted. |
March 27, 2015 Re: Advise for syntax highlighting | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chris | On 2015-03-27 15:03, Chris wrote: > Well, it _is_ a keyword. You cannot write a function called "this", nor > can you use it as a variable name. So yes, it's a keyword = reserved. It depends on how you see it. It's also a special method that just happens to use a keyword as its name. It doesn't have the same meaning as "this" instead a regular method. -- /Jacob Carlborg |
March 27, 2015 Re: Advise for syntax highlighting | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | On Friday, 27 March 2015 at 14:10:22 UTC, Jacob Carlborg wrote:
> On 2015-03-27 15:03, Chris wrote:
>
>> Well, it _is_ a keyword. You cannot write a function called "this", nor
>> can you use it as a variable name. So yes, it's a keyword = reserved.
>
> It depends on how you see it. It's also a special method that just happens to use a keyword as its name. It doesn't have the same meaning as "this" instead a regular method.
Either way, it should be highlighted somehow.
|
March 27, 2015 Re: Advise for syntax highlighting | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | Personal preferences: > * "this" in constructor > > this () {} > > In TextMate functions/methods are highlighted, should this be highlighted as a keyword or as a method? method > * "this" in copy constructor > > this (this) {} > > The "this" parameter, should that be highlighted as a keyword or as a parameter? keyword (because, well, it is not a parameter) > * The "__ctfe" variable > > if (__ctfe) {} > > How should this highlighted? I see a couple of alternatives: > > - not at all > - as a keyword > - as a special recognized built-in symbol, similar to __LINE__ > - as a special recognized library symbol. For example, in the C bundle many of functions in the standard library are specially recognized and highlighted differently. This might not apply here since it's not a library symbol not at all. The fact it is reserved is already denoted by __, otherwise it is just another vairable/symbol. > * __traits identifiers > > __traits(allMembers, Foo); > > In this case "allMembers". Basically the same question and alternatives as for the "__ctfe" variable. this is different from __ctfe as it is actual compiler built-in with special semantics. "special recognized built-in symbol" is probably best fit as it is not listed as keyword either. > * Predefined version identifiers > > version (OSX) {} > > Again, same a question and alternatives as for the "__ctfe" variable. "special recognized built-in symbol" > * Extern identifiers > > extern (C) > > Again, same a question and alternatives as for the "__ctfe" variable. "special recognized built-in symbol" |
March 27, 2015 Re: Advise for syntax highlighting | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dicebot | On 2015-03-27 16:04, Dicebot wrote: > not at all. The fact it is reserved is already denoted by __, otherwise > it is just another vairable/symbol. Doesn't this symbol also have special semantics? -- /Jacob Carlborg |
March 27, 2015 Re: Advise for syntax highlighting | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | On Friday, 27 March 2015 at 15:23:56 UTC, Jacob Carlborg wrote:
> On 2015-03-27 16:04, Dicebot wrote:
>
>> not at all. The fact it is reserved is already denoted by __, otherwise
>> it is just another vairable/symbol.
>
> Doesn't this symbol also have special semantics?
A more pragmatical view would be:
if(__ctf ... Was it __ctfe or __ctfe__?
Easily answered if it has special highlighting.
|
March 28, 2015 Re: Advise for syntax highlighting | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | Vim is setup as: On Friday, 27 March 2015 at 10:34:58 UTC, Jacob Carlborg wrote: > I'm currently updating the TextMate D bundle for D2. I have a couple of questions for how to highlighting some specific code or how other editors/IDE's highlight them. > > * "this" in constructor > > this () {} Keyword (function should be fine, vim doesn't highlight those) > In TextMate functions/methods are highlighted, should this be highlighted as a keyword or as a method? > > * "this" in copy constructor > > this (this) {} Keyword > The "this" parameter, should that be highlighted as a keyword or as a parameter? > > * The "__ctfe" variable > > if (__ctfe) {} > > How should this highlighted? I see a couple of alternatives: > > - not at all > - as a keyword > - as a special recognized built-in symbol, similar to __LINE__ > - as a special recognized library symbol. For example, in the C bundle many of functions in the standard library are specially recognized and highlighted differently. This might not apply here since it's not a library symbol Statement [e.g. debug, return, function, with] (that needs fixed) Probably should be Identifier for consistency [e.g. _arugments, __vptr, _ctor] Which I guess is your third (special recognized built-in), though __LINE__ is a constant in Vim's highlighting [e.g. null, __VERSION__]. > * __traits identifiers > > __traits(allMembers, Foo); > > In this case "allMembers". Basically the same question and alternatives as for the "__ctfe" variable. Identifier > * Predefined version identifiers > > version (OSX) {} > > Again, same a question and alternatives as for the "__ctfe" variable. Identifier > * Extern identifiers > > extern (C) > > Again, same a question and alternatives as for the "__ctfe" variable. Identifier |
Copyright © 1999-2021 by the D Language Foundation