Missing compiler warning?
Jonathan M Davis
jmdavisProg at gmx.com
Mon Oct 21 02:36:34 PDT 2013
On Monday, October 21, 2013 11:24:06 Chris wrote:
> But there you have this. But a function (in the same class) like
>
> void processInput() {
> auto input = // ...
> // 20 lines later
> input = std.string.format("Hello %s!", someString);
> }
>
> Why would one want to write code like this? Why should a
> short-lived local variable assume the name of a class variable?
> This is a source of confusion and I don't consider this good
> practice. Maybe it's just personal taste.
That may very well be bad practice (I certainly wouldn't advise writing code
like that), but it's also not definitively wrong. Unless it's definitely a bug,
I think that the compiler should keep quiet about it, because anything that it
yells about has to be treated as a bug, and we shouldn't be forcing people to
change their code just because there _might_ be a bug in it.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list