digitalmars.D.bugs - [Issue 8634] New: Anonymous function parameters
- d-bugmail puremagic.com (26/26) Sep 09 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8634
- d-bugmail puremagic.com (16/29) Sep 09 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8634
- d-bugmail puremagic.com (9/32) Sep 09 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8634
- Namespace (1/2) Sep 09 2012 And this will never change. ;)
- bearophile (3/5) Sep 09 2012 Who knows, maybe eventually I'll be able to convince GDC
- Namespace (2/8) Sep 09 2012 But he said dmd. :P
- d-bugmail puremagic.com (30/33) Sep 09 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8634
- d-bugmail puremagic.com (13/13) Sep 10 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8634
http://d.puremagic.com/issues/show_bug.cgi?id=8634 Summary: Anonymous function parameters Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: maxim maxim-fomin.ru --- void foo(int) { } void main() { foo(5); } Although anonymous function parameters may be used in function declarations, it seems that dmd doesn't check whether a function declaration is a definition too. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 09 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8634 bearophile_hugs eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bearophile_hugs eml.ccvoid foo(int) { } void main() { foo(5); } Although anonymous function parameters may be used in function declarations, it seems that dmd doesn't check whether a function declaration is a definition too.What's the problem here? foo() not giving a name to its first argument means the programmer is stating foo() never uses its first argument, and the D language allows the programmer to enforce this desire. This feature also allows to avoid "unused argument warnings" once/where such warning is available. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 09 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8634 ---The problem is that such code is likely to be a bug (parameter name was forgotten) and compiler should report about this. BTW dmd doesn't produce any warning for unused variable. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------void foo(int) { } void main() { foo(5); } Although anonymous function parameters may be used in function declarations, it seems that dmd doesn't check whether a function declaration is a definition too.What's the problem here? foo() not giving a name to its first argument means the programmer is stating foo() never uses its first argument, and the D language allows the programmer to enforce this desire. This feature also allows to avoid "unused argument warnings" once/where such warning is available.
Sep 09 2012
BTW dmd doesn't produce any warning for unused variable.And this will never change. ;)
Sep 09 2012
On Sunday, 9 September 2012 at 19:59:02 UTC, Namespace wrote:Who knows, maybe eventually I'll be able to convince GDC maintainers to introduce this warning :-)BTW dmd doesn't produce any warning for unused variable.And this will never change. ;)
Sep 09 2012
On Sunday, 9 September 2012 at 20:19:51 UTC, bearophile wrote:On Sunday, 9 September 2012 at 19:59:02 UTC, Namespace wrote:But he said dmd. :PWho knows, maybe eventually I'll be able to convince GDC maintainers to introduce this warning :-)BTW dmd doesn't produce any warning for unused variable.And this will never change. ;)
Sep 09 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8634The 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 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: -------
Sep 09 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8634 Maxim Fomin <maxim maxim-fomin.ru> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID --- I have no desire for disputes about things which are not necessarily defective (as revealed here) and claimed by D people to be intentional part of the language. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 10 2012