auto -> auto & var

Sean Kelly sean at f4.ca
Fri Mar 17 12:54:09 PST 2006


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.


Sean



More information about the Digitalmars-d mailing list