What is the correct use of auto?

Scott S. McCoy tag at cpan.org
Mon Apr 14 20:00:44 PDT 2008


On Sun, 2008-04-13 at 14:42 -0700, Unknown W. Brackets wrote:
> 
> I think you're trying to say that having autos in examples is like 
> having mines, in that they are possible points of confusion to
> newcomers 
> (who will not know what those things are.)  You may also be trying to 
> say that using auto in examples teaches people to use auto more than 
> they should.

I personally think auto in examples is confusing to new users, depending
on their background they may very well make unsafe assumptions about
what auto is supposed to do.

I do think auto is safe in examples, but only *after* having introduced
foreach loops as an example of how type inference works there.  I find
that's more grokable for a lot of people, after that type inference
makes a lot of sense.  And then they don't assume the "auto" keyword
works like perl's "my" or pike's "object"...they don't assume it's a
declaration of a dynamic type; since they've already had inference
explained to them.  They do then understand it's a placeholder for a
type.

That's what I'd glean, anyway, from a lot of the feedback I see about
auto.




More information about the Digitalmars-d mailing list