Minimizing "reserved" words
Jacob Carlborg via Digitalmars-d
digitalmars-d at puremagic.com
Mon Oct 31 13:45:56 PDT 2016
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?
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list