auto declarations

Jonathan M Davis jmdavisProg at gmx.com
Mon Jan 10 02:19:56 PST 2011


On Monday 10 January 2011 01:59:34 Lars T. Kyllingstad wrote:
> On Fri, 07 Jan 2011 16:30:24 -0800, Jonathan M Davis wrote:
> > On Friday, January 07, 2011 13:32:42 Ellery Newcomer wrote:
> >> auto a = 1, b = null;
> >> 
> >> int a = 1, *b = null;
> >> 
> >> 
> >> [...]
> > 
> > [...]
> > 
> > However, I'm vere suprised that the first one succeeds. I think that it
> > should be reported as a bug. All variables declared on the same line are
> > supposed to have the same type.
> 
> If I remember correctly, TDPL explicitly states that you may use
> automatic type inference to declare variables of different types in one
> line.

Well, it may. I don't know. I don't really believe in declaring multiple 
variables on one line in normal circumstances anyway. However, it's definitely an 
inconsistency in the language, and I would be inclined to argue that it should 
be removed and TDPL errata-ed if it does mention this "feature." I don't see any 
real benefit of allowing this.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list