keyword as struct field

H. S. Teoh hsteoh at quickfur.ath.cx
Sun Feb 20 17:02:21 UTC 2022


On Sun, Feb 20, 2022 at 04:52:30PM +0000, partypooper via Digitalmars-d-learn wrote:
> On Sunday, 20 February 2022 at 15:33:17 UTC, Andrey Zherikov wrote:
> > On Sunday, 20 February 2022 at 11:08:55 UTC, partypooper wrote:
> > > keyword as struct field
> > 
> > I believe this is the case for the most languages - keyword is not
> > allowed as a variable name.
> 
> Yes, but as example in Nim you can surround identifier with backticks
> to omit this issue.

The D convention is to append a `_` to the identifier. From
https://dlang.org/dstyle.html:

	If a name would conflict with a keyword, and it is desirable to
	use the keyword rather than pick a different name, a single
	underscore ‘_’ should be appended to it. Names should not be
	capitalized differently in order to avoid conflicting with
	keywords.


T

-- 
Questions are the beginning of intelligence, but the fear of God is the beginning of wisdom.


More information about the Digitalmars-d-learn mailing list