February 09, 2012 [Issue 3960] Unused local variables not reported | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=3960 --- Comment #20 from Stewart Gordon <smjg@iname.com> 2012-02-09 03:09:09 PST --- (In reply to comment #19) > Now the interface is happy, as is the compiler check, because we made it clear, that we intended to ignore 'b'. Indeed. Some C++ compilers work on the principle that if you named a parameter, you intended to use it, and so issue a warning if you haven't used it. But this bug report is about unused local variables, not unused function parameters. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 09, 2012 [Issue 3960] Unused local variables not reported | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=3960 --- Comment #21 from Marco Leise <Marco.Leise@gmx.de> 2012-02-09 03:48:32 PST --- You are right. Since local variables and parameters are related, it could be that the person fixing this also thinks about the situation for function parameters. A new bug report or enhancement request would cause twice the work in this case. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 09, 2012 [Issue 3960] Unused local variables not reported | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=3960 --- Comment #22 from Jonathan M Davis <jmdavisProg@gmx.com> 2012-02-09 08:42:51 PST --- I know that Walter is against having warnings or errors for unused parameters (he has _definitely_ said as much on the newsgroup), but he may feel differently about local variables. The spec specifically says that unused _local_ variables are an error. So, Walter probably views those differently, which makes some sense - particularly since they aren't affected by overriding and the like. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 18, 2012 [Issue 3960] Unused local variables not reported | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=3960 --- Comment #23 from timon.gehr@gmx.ch 2012-02-18 13:05:26 PST --- (In reply to comment #19) > (In reply to comment #18) > > Whether or not a parameter is used is unrelated to whether or not it has a name. > > You can't use an unnamed parameter, or can you? > I can: import std.stdio; double foo(double){return _param_0;} void main(){writeln(foo(2));} -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 08, 2012 [Issue 3960] Unused local variables not reported | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=3960 --- Comment #24 from bearophile_hugs@eml.cc 2012-03-08 10:09:12 PST --- I have found an interesting information. In Go language an unused variable is an _error_: package main func main() { x := 10; } prog.go:3: x declared and not used -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
April 25, 2012 [Issue 3960] Unused local variables not reported | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=3960 --- Comment #25 from bearophile_hugs@eml.cc 2012-04-24 18:16:12 PDT --- See also Issue 2197 and Issue 4694 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
April 26, 2012 [Issue 3960] Unused local variables not reported | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=3960 --- Comment #26 from Jonathan M Davis <jmdavisProg@gmx.com> 2012-04-26 10:43:42 PDT --- I think that issue# 7989 is a great argument for why there shouldn't be any warnings or errors for unused variables. Such would needlessly make writing template constraints harder. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
April 26, 2012 [Issue 3960] Unused local variables not reported | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=3960 --- Comment #27 from Stewart Gordon <smjg@iname.com> 2012-04-26 11:47:59 PDT --- This discussion is relevant to both this and issue 7989, so I'm continuing it on digitalmars.D.learn under the existing "Docs: Section on local variables" thread. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
April 26, 2012 [Issue 3960] Unused local variables not reported | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=3960 --- Comment #28 from bearophile_hugs@eml.cc 2012-04-26 13:04:47 PDT --- (In reply to comment #26) > I think that issue# 7989 is a great argument for why there shouldn't be any warnings or errors for unused variables. Such would needlessly make writing template constraints harder. The fact that in some uncommon situations you want to define a variable and not use it, can't justify the lack of a compile reaction to unused variables. There are solutions to that problem, Steven Schveighoffer suggests something like: pragma(used) int x; Or: @used int x; -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
April 26, 2012 [Issue 3960] Unused local variables not reported | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=3960 --- Comment #29 from Stewart Gordon <smjg@iname.com> 2012-04-26 15:05:39 PDT --- (In reply to comment #28) > There are solutions to that problem, Steven Schveighoffer suggests something like: > > pragma(used) int x; > > Or: > @used int x; Does this gain anything over what I suggested in issue 7989 comment 3? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation