Proposal: new variable definition operator
jovo
jovo at at.home
Sat Apr 21 11:43:01 PDT 2007
Chris Nicholson-Sauls Wrote:
> >
> > From the D docs (Attributes):
> > "The auto attribute is used when there are no other attributes
> > and type inference is desired."
>
> Same meaning, slightly different words, to this: "If type inference is desired, and there
> is no special storage class, you may specify the explicit default storage class attribute
> 'auto' to trigger inference."
>
I read this sentence as is: The auto attribute is _only_ used when
there are no other attributes and type inference is desired. Auto
has not other meaning.
And _all_ implementation is consistent.
Compiler just ignores auto in any other place.
Look at:
auto int x; // global, auto is ignored
void f() {
auto static int x = 12; // static, auto is ignored
...
auto SomeClass x = new SomeClass(); // sole exception
I suspect this exception is needed for backward compatibility. It is
reminiscence of old auto.
>From Changelog for D 0.174:
"scope can now be used for RAII declarations; use auto
for type inference"
>
> All of the following declerations experience type inference:
> # auto alpha = 1;
> # const beta = 2;
> # final gamma = 3;
> # invariant delta = 4;
> # scope epsilon = 5;
> # static zeta = 6;
>
OK I know that. It's exactly as it is stated in docs.
jovo
More information about the Digitalmars-d
mailing list