auto declarations
Piotr Szturmaj
bncrbme at jadamspam.pl
Fri Jan 7 13:42:08 PST 2011
Ellery Newcomer wrote:
>
> auto a = 1, b = null;
>
> int a = 1, *b = null;
>
>
> The first is accepted by dmd, and it should result in typeof(a) == int
> and typeof(b) == void*. It is somewhat contradictory to the error
> message resulting from the second:
>
> multiple declarations must have the same type, not int and int*
>
> I am skeptical of dmd's permitting the first. Does anyone else see any
> utility in it?
Personally, I like it. In second line you specify int type, and list of
*int* variables.
In first line you specify list of initialized variables which types
should be inferred automatically. I see no reason why first line should
not be permitted.
If one would need several variables of one type, why he wouldn't specify
exact type instead of using 'auto'?
More information about the Digitalmars-d-learn
mailing list