Constness Naming Proposal
Chad J
gamerChad at _spamIsBad_gmail.com
Sat Aug 25 18:55:48 PDT 2007
Perhaps we should name head constness and tail constness as such:
hiro = Head Is Read Only
tiro = Tail Is Read Only
Where "hiro" and "tiro" are new keywords for constness.
These names are made to reflect the notions of constness presented in
the "Future of D, Part 2" talk at the D conference.
The only problem with it that I can think of is that the meanings of
these algorithms aren't clear. To that, I say that nothing short of a
very jargon laden sentence would give a clear meaning of this concept.
The advantages:
- Very unlikely these are used much as variable names, if at all.
Almost no code refactoring for adding these keywords.
- To newbies they should scream "Read the reference!"
- Allows us to reserve "const" for things that are truly CONSTANT*.
- Also not confusable with constant things (sorta same as above one).
- You can also make other keywords from the paradigm, ex: biro = body is
read only, airo = all is read only (or aaro?).
- Short 4 characters, easy to type :) Remember this will likely be used
a lot (here a const, there a const).
* In the "Future of D, Part 2" talk there was also mention of functions
that take constant parameters. The proposed syntax was like so:
void foo( static int bar, int baz )
{
// bar is a compile time constant, baz is runtime variable
}
If we freed up const from constness, we could have this:
void foo( const int bar, int baz ) { ... }
thus it is clear to non-C/C++ users that bar is constant. The C/C++
users will get compile time errors if they use it incorrectly; nothing
too insane. Definitely worth it to drop the horrid "const" naming from
C/C++ IMO.
Another note on this use of abbreviation, for those of us who are like
me and usually don't like obfuscated abbreviations at all:
There is no english/technical word for constness. We are condensing a
few sentences or paragraphs of technical writing and meaning into a
keyword or two. We might as well make new words up.
More information about the Digitalmars-d
mailing list