auto, var, raii,scope, banana
Nils Hensel
nils.hensel at web.de
Tue Jul 25 23:23:25 PDT 2006
Regan Heath schrieb:
> I don't use "var" specifically but I have been known to use tmp, x, y,
> i, j, p, s, n, .. for all my temporary and/or meaningless variables.
> They typically have a short scope life and I can't see a problem with
> this practice.
I don't either as there will never be a one letter keyword. As for "tmp"
it is a lot more descriptive than "var". Not all variables are holding
temporary values but all are "variable" as their name already implies.
Even i(=index) or n(=number of) bear a meaning in a mathematical
context. I'm not all against short variable names (though I try to
usually be more expressive) but their name should hint at their content
or use. "var" doesn't hint at anything.
> I think Kris's point is that of the two choices 'var' and 'auto' the
> latter is less likely to annoy someone by colliding with existing user
> variables. The point is valid so long as the group of 'var' users is
> bigger than the group of 'auto' users, even if both groups are small.
One should also consider future users of D since we haven't even reached
1.0 yet. Since no one else already uses "auto" for this purpose but a
lot of languages use "var" I believe it to be the more intuitive option.
> C++ may be an abomination but it does have 'market' dominance. You have
> to ask 'why'. You should learn from your 'enemies' ;)
But those reasons are mainly historical and may be summed up by "it's
the least of all evils". This does not even hold true anymore. At least
not when you look at language constructs and elegance. It's clearly
"grown" not designed.
Regards,
Nils
More information about the Digitalmars-d
mailing list