auto -> auto & var

Chris Miller chris at dprogramming.com
Sun Mar 19 08:25:39 PST 2006


On Fri, 17 Mar 2006 15:54:09 -0500, Sean Kelly <sean at f4.ca> wrote:

> Georg Wrede wrote:
>> Unknown W. Brackets wrote:
>>> Here's what I hate about var: I use JavaScript a lot (this happens  
>>> when you make interactive websites for a living.)  What do you mean,  
>>> that's not a reason?
>>>
>>> Sure it is.  In JavaScript and other scripting languages, this would  
>>> be valid:
>>>
>>> var x;
>>>
>>> // Okay, let's make it an array!
>>> x = new Array(1, 2, 3);
>>>
>>> // Actually, you know what, I take that back.
>>> x = "1,2,3";
>>>
>>> // Come to think, this might be better...
>>> x = {0: 1, 1: 2, 2: 3};
>>>
>>> // No, no, actually it just needs one.  How clueless of me.
>>> x = 1;
>>  Breaking the unfortunate "auto" into two separate words would be very  
>> good. But like you say, "var" may not be a good candidate. Especially  
>> when a change in the language should strive to _improve_ it, and not  
>> merely substitute one problem for another.
>
> For what it's worth, the next iteration of C++ will add 'auto' as an  
> auto-type keyword, so for the sake of consistency I think 'var' should  
> not be used in D.
>

I think C# is (going to be) using var, but C# doesn't really follow  
C-descendant trend in some areas. I personally don't think var is a good  
choice, it reminds people of silly scripting languages.



More information about the Digitalmars-d mailing list