Thread overview | |||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
January 28, 2014 Keywords: How to trick the compiler? | ||||
---|---|---|---|---|
| ||||
Is there a simple way to trick the compiler (e.g. with alias), if a keyword conflicts with a function/method, e.g. as in a HTML document: auto docBody = document.body; // corresponding method (will not compile due to body being a keyword) @property auto body() { // simplified code return this.getElementByTagName("body"); } |
January 28, 2014 Re: Keywords: How to trick the compiler? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chris | On Tuesday, 28 January 2014 at 11:22:10 UTC, Chris wrote: Nope, just choose a different name. |
January 28, 2014 Re: Keywords: How to trick the compiler? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stanislav Blinov | On Tuesday, 28 January 2014 at 11:24:33 UTC, Stanislav Blinov wrote:
> On Tuesday, 28 January 2014 at 11:22:10 UTC, Chris wrote:
>
> Nope, just choose a different name.
Cripes! There goes my API ...
|
January 28, 2014 Re: Keywords: How to trick the compiler? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chris | On Tuesday, 28 January 2014 at 11:38:16 UTC, Chris wrote:
> On Tuesday, 28 January 2014 at 11:24:33 UTC, Stanislav Blinov wrote:
>> On Tuesday, 28 January 2014 at 11:22:10 UTC, Chris wrote:
>>
>> Nope, just choose a different name.
>
> Cripes! There goes my API ...
Aww, a bit of underscoring hasn't hurt anyone yet. :)
|
January 28, 2014 Re: Keywords: How to trick the compiler? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chris | On Tuesday, 28 January 2014 at 11:22:10 UTC, Chris wrote:
> Is there a simple way to trick the compiler (e.g. with alias), if a keyword conflicts with a function/method, e.g. as in a HTML document:
>
> auto docBody = document.body;
>
> // corresponding method (will not compile due to body being a keyword)
>
> @property auto body() {
> // simplified code
> return this.getElementByTagName("body");
> }
Write in with an uppercase. ;)
Int, If, Template...
|
January 28, 2014 Re: Keywords: How to trick the compiler? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Namespace | On Tuesday, 28 January 2014 at 12:25:19 UTC, Namespace wrote:
> On Tuesday, 28 January 2014 at 11:22:10 UTC, Chris wrote:
>> Is there a simple way to trick the compiler (e.g. with alias), if a keyword conflicts with a function/method, e.g. as in a HTML document:
>>
>> auto docBody = document.body;
>>
>> // corresponding method (will not compile due to body being a keyword)
>>
>> @property auto body() {
>> // simplified code
>> return this.getElementByTagName("body");
>> }
>
> Write in with an uppercase. ;)
> Int, If, Template...
I've also seen some people append _: body_, int_ etc.
|
January 28, 2014 Re: Keywords: How to trick the compiler? | ||||
---|---|---|---|---|
| ||||
Posted in reply to simendsjo | On Tuesday, 28 January 2014 at 12:43:59 UTC, simendsjo wrote:
> I've also seen some people append _: body_, int_ etc.
It is what current Phobos style guide suggests.
|
January 28, 2014 Re: Keywords: How to trick the compiler? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dicebot | On Tuesday, 28 January 2014 at 12:45:37 UTC, Dicebot wrote:
> On Tuesday, 28 January 2014 at 12:43:59 UTC, simendsjo wrote:
>> I've also seen some people append _: body_, int_ etc.
>
> It is what current Phobos style guide suggests.
Yes, I've used it, but don't like it. Maybe I'll opt for the uppercase solution.
|
January 28, 2014 Re: Keywords: How to trick the compiler? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chris | On 1/28/14, Chris <wendlec@tcd.ie> wrote:
> Is there a simple way to trick the compiler (e.g. with alias), if a keyword conflicts with a function/method, e.g. as in a HTML document:
>
> auto docBody = document.body;
"body" is probably the most frequent issue I run into when porting C/C++ code to D.
I really wonder whether the rule could be relaxed a little bit.
|
January 28, 2014 Re: Keywords: How to trick the compiler? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | On Tuesday, 28 January 2014 at 12:57:02 UTC, Andrej Mitrovic wrote:
> "body" is probably the most frequent issue I run into when porting
> C/C++ code to D.
>
> I really wonder whether the rule could be relaxed a little bit.
o_O How?
|
Copyright © 1999-2021 by the D Language Foundation