On Monday, 31 October 2016 at 20:45:56 UTC, Jacob Carlborg wrote:
The "reserved" words I'm referring to are not necessarily keywords in the language but otherwise words that should be avoided, especially for defining methods in aggregates. I'm mostly thinking of built-in properties like .init, .classinfo, .sizeof, .outer and so on.

All of the above can be used as variable names. Some of the above names can be used as methods in aggregates but some cannot. Of the above names only "sizeof" cannot be used as a method name.

Would it be better to try to minimize these special words and instead use either compiler recognized functions/templates or something like __traits? If they were compiler recognized functions, defined somewhere in druntime, the normal language lookup rules could be used to disambiguate the compiler recognized functions from user defined functions. Or if a __trait is used, that would have it's own namespace and not cause any conflicts.

In the latest release of DMD (2.072.0) TypeInfo.init has been deprecate in favor of TypeInfo.initializer. That would not have been needed if .init wasn't a built-in property but instead a compiler recognized function.

Thoughts? Too late to change, to much could would break?

This information from Wiki, I hope it will be useful. That general reserved words and keywords need not coincide, but in most modern languages keywords are a subset of reserved words, as this makes parsing easier, since keywords cannot be confused with identifiers. In some languages, like C or Python, reserved words and keywords coincide, while in other languages, like Java, all keywords are reserved words, but some reserved words are not keywords – these are "reserved for future use". In yet other languages, such as the older languages ALGOL, FORTRAN and PL/I, there are keywords but no reserved words, with keywords being distinguished from identifiers by other means. This makes parsing more difficult with look-ahead parsers necessary.

Reply via email to