Notes on the Phobos style guide
Adam Ruppe
destructionator at gmail.com
Mon Aug 16 16:29:27 PDT 2010
On 8/16/10, bearophile <bearophileHUGS at lycos.com> wrote:
> 'auto' in C++0x is a good and useful feature, just as it is useful in D, but
> as I have explained it has real risks, so it must be used with moderation,
> if you use it everywhere in the code, your code becomes harder to understand
> and modify.
I see it as the opposite: it is about the same to understand, and much
easier to modify.
For understanding, the type is determined on the right side of the
thing anyway, and is usually plainly obvious, or if not, the type
doesn't really matter. Examples of the former are new statements or
literals, and examples of the latter are a lot of the fancy ranges'
return values.
Besides, worst case, you have to scroll up a few lines to see the
original type, but it is there if you need it. It isn't like a dynamic
language where the type can be anything passed in and can change at
random at any time. It is set in one place and stays consistent.
For modification, it makes things easier since you don't need to
repeat yourself. You can make a change in one place, and that change
automatically propagates. Again, unlike dynamic languages, the type is
still consistent: if the change breaks things down the line, the
compiler will tell you, whether you use auto or not.
More information about the Digitalmars-d
mailing list