What is the correct use of auto?

Georg Wrede georg at nospam.org
Sun Apr 13 14:25:47 PDT 2008


Unknown W. Brackets wrote:
> Robert Fraser wrote:
>> Actually, I would run it on all the Tango examples, since "auto"
>> has no place in examples -- If I'm learning how to use an API, I
>> want to know the actual types of the stuff I'm getting without
>> looking up every function.

> I completely disagree.  Especially when your dogfood is good, you
> should share it and not horde it for yourself.
> 
> Teaching newbies to program differently than you think is best seems 
> wrong to me.

The last phrase I entirely agree with. Replacing earlier "when your 
dogfood is good" with "when your dogfood is good for you".

Now, what is different here is, there's another thing at issue here than 
how newbies/old hands should program. In other words, pedagogically, 
this is an exception case.

Why? Well, here the point is not whether to encourage or discourage the 
use of "auto". The point is (in the examples which we're talking about, 
anyway), all of those examples TALK ABOUT SOMETHING ELSE than if you 
should use auto or not. So, to make the issue clear, one should have 
"unabridged" D code visible.

I'm both sorry, and angry, over that I simply don't seem to express this 
more precisely, nor more convincingly -- sorry and angry with myself.

Those of you who have kids, must have been in the situation where you've 
"known better, but can't say _why_ to your kids in such language and 
terms that they'd get convinced". I'm there now, with this issue.

To sum it up, "auto" should /never/ appear in any example code (either 
here nor in DDJ), all examples that are not /directly/ associated with 
"auto" should simply not contain it. BUT, on the First Page of Proper 
Conduct in D, "auto" should be prominently displayed as the Proper Way.



More information about the Digitalmars-d mailing list