Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
September 26, 2009 [Issue 3345] New: Static and nonstatic methods with the same name should be allowed | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=3345 Summary: Static and nonstatic methods with the same name should be allowed Product: D Version: unspecified Platform: Other OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: andrei@metalanguage.com --- Comment #0 from Andrei Alexandrescu <andrei@metalanguage.com> 2009-09-26 10:37:06 PDT --- Consider: class Widget { int fun() { return 1; } static int fun() { return 2; } } void main() { writeln(Widget.fun()); // should print 2 writeln((new Widget).fun()); // should print 1 } This should work. Otherwise there is no way to explain how .classinfo works in terms of D facilities. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 30, 2011 [Issue 3345] Static and nonstatic methods with the same name should be allowed | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | http://d.puremagic.com/issues/show_bug.cgi?id=3345 David Simcha <dsimcha@yahoo.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dsimcha@yahoo.com --- Comment #1 from David Simcha <dsimcha@yahoo.com> 2011-08-30 07:38:34 PDT --- What should be the semantics if there's **only** a static method and no nonstatic method, i.e.: class Widget { static int fun() { return 2; } } void main() { // Does this print 2 or not compile? writeln((new Widget).fun()); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 30, 2011 [Issue 3345] Static and nonstatic methods with the same name should be allowed | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | http://d.puremagic.com/issues/show_bug.cgi?id=3345 Steven Schveighoffer <schveiguy@yahoo.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |schveiguy@yahoo.com --- Comment #2 from Steven Schveighoffer <schveiguy@yahoo.com> 2011-08-30 07:49:41 PDT --- See proposed enhancement: issue 6579 I think David's example should not compile. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 30, 2011 [Issue 3345] Static and nonstatic methods with the same name should be allowed | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | http://d.puremagic.com/issues/show_bug.cgi?id=3345 --- Comment #3 from David Simcha <dsimcha@yahoo.com> 2011-08-30 08:27:11 PDT --- I would argue that it should be allowed because there's no ambiguity, for two reasons: 1. That's the way it already works and changing it would break code and probably TDPL. 2. If we're going to make things more verbose, more annoying for generic code and different from what people from a C++ or Java background expect, we'd better have a compelling reason. Your example in Bug 6579 doesn't cut it. The root of the problem is that reset() is a poorly chosen name, not that allowing static methods to be called via an instance is a bad feature. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 30, 2011 [Issue 3345] Static and nonstatic methods with the same name should be allowed | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | http://d.puremagic.com/issues/show_bug.cgi?id=3345 --- Comment #4 from Steven Schveighoffer <schveiguy@yahoo.com> 2011-08-30 08:47:55 PDT --- I don't want to drag discussions for bug 6579 here, so I responded to your argument in that bug. -- 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