auto, var, raii,scope, banana

Regan Heath regan at netwin.co.nz
Tue Jul 25 16:35:27 PDT 2006


On Tue, 25 Jul 2006 20:14:52 +0200, Nils Hensel <nils.hensel at web.de> wrote:
> kris schrieb:
>> Don has a good point: changing to "var" would cause conflict with  
>> existing variable-names.
>
> I'm sorry but I don't believe there are many programmers out there  
> actually using something as undescriptive as "var" as a regular  
> identifier. I also strongly believe that no one should. It's the  
> implication of a maintenance nightmare.
> I don't intend to insult Don in any way but it's a horrible practice  
> IMNSHO that should not be preserved.

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.

> So let's not focus on some odd minority but rather on the wide use of  
> "var" in the context of type inference and dynamic typing.

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.

> Also I don't think that it's a good habit to be looking at how C++ does  
> something unless one is looking for a bad example. My main reason for  
> interest in D is because personally I'm fed up with C++ and consider it  
> an abomination and a major PITA.

C++ may be an abomination but it does have 'market' dominance. You have to  
ask 'why'. You should learn from your 'enemies' ;)

Regan



More information about the Digitalmars-d mailing list