Phobos examples and auto

Somedude lovelydear at mailmetrash.com
Sun Nov 6 01:19:15 PST 2011


Le 06/11/2011 05:29, Steve Teale a écrit :
> On Sat, 05 Nov 2011 15:14:14 -0500, Andrei Alexandrescu wrote:
> 
>>>> If we avoid "auto" in documentation examples but we do use it in
>>>> everyday code, we effectively foster a style that's foreign and
>>>> non-idiomatic to newcomers.
> 
> Andrei,
> 
> I don't use auto in everyday code, in fact I don't think I've ever used 
> it at all. I've been with D for some years now, but apparently I write 
> 'foreign and non-idiomatic' D. This goes just a tad beyond patronizing 
> your reader.
> 
> Can you write us a brief article that will convince me of its benefits, 
> and the error of my ways please. There's no Borders where I live, and 
> Amazon does not deliver to Africa, so I don't have the benefit of your 
> book.
> 
> Steve
I would say auto removes a lot of redundancy in code, and redundancy is
usually bad.
I guess the best way to see its advantages is to rewrite some of your
code with auto everywhere you can. You should eventually see that the
code is far more legible and cleaner than before.
auto really is a small advantage that works wonders in this regard.
As Jonathan M. Davis stated very well, I expect it to have a huge impact
on C++11 code legibility, especially if it is used in libraries as well
as in application code.

Another reason, is it makes changing types easier, both for humans and
for automated tools, because you only have to change types where necessary.

Dude


More information about the Digitalmars-d mailing list