I'm not sure all the new warnings are good, at least not as default.
In the case of
void f(string filename) { }
there might not be a choice of removing the argument.
In the case of e.g.
foreach(my_mapping; string name; string value) werror("%O\n", value);
the unused name-variable provides possibly helpful documentation. I think what you will see in practice is that programmers will do
foreach(my_mapping;; string value) werror("%O\n", value);
and not
foreach(my_mapping; string name; string value) { name; werror("%O\n", value); }
resulting in a codebase that is harder to work with and extend.
Excellent point, in both cases. Particularly the empty function can be needed, to pass as a do-nothing callback argument that must match that function signature -- but the documentative aspect is every bit as relevant.
A wild and probably bad idea:
Make it possible to declare variables as non-usable. Like this:
void f(!string filename) { } //OK
void f(!string filename) { write(filename); } //Throws error void f(!string filename) { string filename; } //Throws error
and of course:
foreach(my_mapping; !string name; string value) werror("%O\n", value);
I guess it just adds complexity with no real benifits. It can maybe be good to have in a (huge) function to make sure a global variable isn't used anywhere in it.
Why not simply go for the C++ solution:
void f(string) { } //OK
If the parameter isn't named, there's no way of using it anyway.
If it isn't named you'd have to explicitly document it though (if you want documentation).
to mark an unsuable variable a form like void(string) foo would be more in line with exiting pike syntax
greetings, martin.
But in the end it's a solution looking for a problem. It's not a warning that should be on by default, or even with strict_types.
On Mon, 07 Jan 2008 06:00:01 +0100, Peter Bortas @ Pike developers forum 10353@lyskom.lysator.liu.se wrote:
But in the end it's a solution looking for a problem. It's not a warning that should be on by default, or even with strict_types.
100% ack.
KISS
Regards, Bernd
They are very good, from my point of view. I don't want to clutter the namespace with things I don't use.
However, I can agree that it may be best to have them as an option so that end-users don't have to see them all the time.
I agree that it's something good to have in the toolbox for when you want to clean up the code after a debug session of something, but not normally.
pike-devel@lists.lysator.liu.se