http://d.puremagic.com/issues/show_bug.cgi?id=8634



--- Comment #3 from bearophile_h...@eml.cc 2012-09-09 13:35:05 PDT ---
(In reply to comment #2)

> The problem is that such code is likely to be a bug (parameter name was
> forgotten) and compiler should report about this.

I care a lot about removing bug-prone situations from D language. And I think
C# language acts as you ask. Generally C# designers are very careful in
avoiding bug-prone features.

But in general it's not so common to forget to add a name for the argument. And
even in the cases where I have forgotten to put the argument name, this is
usually not a big problem, because the compiler doesn't find the name you are
using inside the function, and gives you a nice compilation error at the first
usage attempt, close enough to the function signature (unless your functions
are really long).

In theory one bug-prone situation is when you use a name thinking it's the name
of a local argument, while you have not given a name to the argument, and you
have a name in an outer scope that is the same. So you are actually using the
name of the outer scope. In practice my diary of bugs shows I have never hit
this bug, also because it's generally a good practice to not define local names
equal to outer names.

So unless you have evidence that this is a common enough bug (even few
anecdotes are enough to keep this discussion open) I think this bug report
should be closed.


> BTW dmd doesn't produce any warning for unused variable.

I know, but probably someday some D compiler will report them. It's an useful
feature and it's not too much hard to implement. All the major C++ compilers
have an option to report them.

But note here I was not referring to a generic "unused variable" warning, I was
referring to more specifically to a "unused argument" warning. If you omit the
argument name, the warning is silenced.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to