auto: useful, annoying or bad practice?
Nick Sabalausky
a at a.a
Wed May 2 00:01:42 UTC 2018
I'm a die-hard static typing fan, hate dynamic languages, heck I
dont even like structural typing (ex, as used by D ranges). And
that's exactly why I *love* auto. It lets you have static typing
without turning programming into a 2000's-era C++/Java-style
royal anti-DRY PITA.
I also think auto is especially nice for NOT requiring a
heavy-weight IDE, because it makes refactorings and type renaming
much simpler.
In the very rare case that I'm not clear what type a var is,
first of all, that's usually a sign something else is wrong with
the code, and secondly, that's trivially answered by tossing in a
"pragma(msg, typeof(xxxx))".
Now, all that said, using auto for a function signature's return
type shouldn't usually be done, except in very careful, specific
"voldemort type" kinds of situations (and even then, I dont see a
real big point).
More information about the Digitalmars-d
mailing list