Class-related queries [was: Re: 'Undefined reference' linking

bearophile bearophileHUGS at
Fri Apr 9 16:48:39 PDT 2010

Lars T. Kyllingstad:
> You don't have to write 'auto' to get type inference.  You just have to 
> have something that signifies to the compiler that a variable is 
> declared.  All of these are valid:
>     auto x = 123;         // x is int
>     const y = 1.23;       // y is const(double)
>     static z = "hello";   // z is string
>     scope f = new Foo(i); // f is Foo
> It is a common belief that 'auto' means automatic type inference.  It 
> doesn't.  'auto' is a storage class, the same as in C:

Thanks to you I am starting to understand, and I think it's a little strange :-) I think I prefer a keyword in the language to denote "use type inferencing here", orthogonal to the other attributes like scope or const (in C# the keyword to ask for type inference is "var": ).
In the end the different is very small, but you, Don, and others have had to bang this in my head a dozen times before I have started to understand it :-(


More information about the Digitalmars-d-learn mailing list