Is D 0.163 D 1.0?
Don Clugston
dac at nospam.com.au
Tue Jul 25 06:20:13 PDT 2006
Derek wrote:
> On Tue, 25 Jul 2006 10:31:53 +0200, Don Clugston wrote:
>
>> Nooooooooo!!!!
>> Am I the only person who has hundreds of local variables called 'var'?
>> (mostly variants in Win32 code).
>
> LOL! You deserve the pain then for choosing such a lame identifier!
Yes, it's as lame as 'x', and deliberately so.
It's lamer as a keyword, IMHO. It's not an English word. 'auto' has been
widely promoted for exactly that purpose in C++, and 'var' had a
completely different meaning in Pascal. I cannot understand the
attraction to 'var'.
>> A quick google search for 'var cpp' showed a million hits, a fair chunk
>> of them are local variables in C++ code. It's a very popular variable name.
>
> Oh my Bob! Doesn't anyone go to programming 101 anymore? Why make life hard
> for yourself by picking identifier names that are likely to clash with
> keywords *and* that don't help code readers.
Because meaningless local variables/parameters should not have
meaningful names; otherwise, you're being _unhelpful_ to code readers!
The most common meaningless names I use are 'x', 'y', 'n', 'p', 'q',
'val' and 'var', and 'arr'.
I guess I never went to programming 101.
> Rule#23: Dealing with Identifier Names.
> [a] Ensure your identifiers are not valid English words.
> [b] Ensure your identifiers either contain a mix of UPPER and
> lowercase characters or contain an underscore or both.
> [c] Ensure your identifiers never contain digits.
The main time I do this is with constructions of the form...
template (P1, P2, P3, P4)
void func(P1 p1, P2 p2, P3 p3, P4 p4)
(where you'd like them to be an array, but the language doesn't allow
it). How would you do it?
> [d] Ensure your identifiers have at least three (3) characters.
Never heard that one before. What's the reason?
> - Exceptions -
> [e] Single character identifiers, which should always be lowercase.
> [f] Method names can be valid words, but must have mixed case.
> [g] Anything your supervisor signs off on.
Fine, but I think it's reasonable to assume that any new keyword will be
either an English word, very obscure, or most likely both. Given that
the number of new keywords will be *extremely* small, I don't think it
makes much sense to have the risk of a collision be a major driver of
naming convention. I really don't like your rule [b], when applied to
local variables and parameter names, I think it reduces legibility, but
I think it's reasonable for method names.
More information about the Digitalmars-d
mailing list