Andrei Alexandrescu wrote:
bearophile wrote:
Andrei Alexandrescu:
If it were an error, I wouldn't let it go.
It's an error. It will lead to troubles.
Well at most you could say it's error-prone, something that is easier to
argue. The problem is that forcing it into an error makes quite a number
of valid uses impossible. An example is a logging application that
provides you a number of pieces of information (date, time, message,
etc.) and you get to specify how they should be formatted. Oftentimes
you'd choose to ignore some data.
Andrei
Fair enough. But then let's split off a version of the function which
allows unused arguments. For most users, in most cases, unused
arguments are indicative of an error.
Case in point: I have been bitten by this perhaps half a dozen times
*already* porting older code. This code used to work fine:
writefln("The value is: %d", myVar, ". Do something!");
Now, it interprets the trailing string as an unused argument, and
ignores it (silently). Ugh.
Ofc, looking back, I don't like that old coding style...I'm migrating
back more to C-style (give the whole format string first). But the fact
that I had a *silent* error was frustrating.
Russ