Thread overview | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
February 17, 2012 [Issue 7534] New: Allow attribute-overloading of an overridden method | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=7534 Summary: Allow attribute-overloading of an overridden method Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: timon.gehr@gmx.ch --- Comment #0 from timon.gehr@gmx.ch 2012-02-17 11:34:45 PST --- Also see: http://d.puremagic.com/issues/show_bug.cgi?id=3757 class C{ void foo(){} } class D : C{ override void foo(){} void foo()const{} } Currently this is illegal. Both child class methods are assumed to override the parent class method: Error: D.foo multiple overrides of same function Only the first child class method should override the parent class method and the second child class method would introduce an additional overload on const. Similar observations apply to shared/immutable/inout functions. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 18, 2012 [Issue 7534] Allow attribute-overloading of an overridden method | ||||
---|---|---|---|---|
| ||||
Posted in reply to timon.gehr@gmx.ch | http://d.puremagic.com/issues/show_bug.cgi?id=7534 yebblies <yebblies@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |yebblies@gmail.com --- Comment #1 from yebblies <yebblies@gmail.com> 2012-02-18 20:36:00 EST --- I assume this is what Walter meant when he said contravariance causes problem with overloading. Are you sure it's a good idea to have the first overload selected? This would mean removing it would make the second overload the overrider. While it will be different once omitting 'override' is an error, override does not change semantics in any other case, it just confirms and enforces what the compiler determines anyway. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 18, 2012 [Issue 7534] Allow attribute-overloading of an overridden method | ||||
---|---|---|---|---|
| ||||
Posted in reply to timon.gehr@gmx.ch | http://d.puremagic.com/issues/show_bug.cgi?id=7534 --- Comment #2 from timon.gehr@gmx.ch 2012-02-18 03:26:40 PST --- The idea is that code like this would be allowed too: class C{ void foo(){} } class D : C { alias C.foo foo; // inherit from super class void foo()const{} // additional overload } I agree that implementing this requires making omission of override an error. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 18, 2012 [Issue 7534] Allow attribute-overloading of an overridden method | ||||
---|---|---|---|---|
| ||||
Posted in reply to timon.gehr@gmx.ch | http://d.puremagic.com/issues/show_bug.cgi?id=7534 --- Comment #3 from timon.gehr@gmx.ch 2012-02-18 03:33:58 PST --- NVM, that would break code like the following: class C{ void foo(){writeln(1);} void foo()immutable{writeln(2);} } class D : C { alias C.foo foo; void foo()const{writeln(3);} // currently overrides 2 } I don't know if it is worth the effort. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 18, 2012 [Issue 7534] Allow attribute-overloading of an overridden method | ||||
---|---|---|---|---|
| ||||
Posted in reply to timon.gehr@gmx.ch | http://d.puremagic.com/issues/show_bug.cgi?id=7534 --- Comment #4 from yebblies <yebblies@gmail.com> 2012-02-18 23:02:42 EST --- Heh, that last example should either override both or be an ambiguity error. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 24, 2012 [Issue 7534] Allow attribute-overloading of an overridden method | ||||
---|---|---|---|---|
| ||||
Posted in reply to timon.gehr@gmx.ch | http://d.puremagic.com/issues/show_bug.cgi?id=7534 deadalnix <deadalnix@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |deadalnix@gmail.com --- Comment #5 from deadalnix <deadalnix@gmail.com> 2012-02-24 04:32:05 PST --- As I explained somewhere in the news group, the current behavior is inconsistent. We have to choose is const is a characteristic of the method or of its arguments. If it is a characteristic of its argument (the hidden argument this), then const and non const method are 2 different methods, and shouldn't override each other. If this is a characteristic of the method, then we shouldn't be able to define both const and non const version of the same method, just like we cannot define both pure and impure version of a same function. This problem is closely related to the return type const qualifier one, both are symptoms of the same misconception in D spec. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 03, 2012 [Issue 7534] Allow attribute-overloading of an overridden method | ||||
---|---|---|---|---|
| ||||
Posted in reply to timon.gehr@gmx.ch | http://d.puremagic.com/issues/show_bug.cgi?id=7534 --- Comment #6 from Kenji Hara <k.hara.pg@gmail.com> 2012-03-03 07:01:05 PST --- I think this is almost same as issue 3757, and I think additional overload in derived class is useful and should work. Example: // after fixing object const correctness (bug 1824) class Object { bool opEquals(const Object o); //... } class C { alias super.opEquals opEquals; // additional overload for mutable object equality override bool opEquals(Object o) { // special processing, e.g. caching return super.opEquals(o); } } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 03, 2012 [Issue 7534] Allow attribute-overloading of an overridden method | ||||
---|---|---|---|---|
| ||||
Posted in reply to timon.gehr@gmx.ch | http://d.puremagic.com/issues/show_bug.cgi?id=7534 Kenji Hara <k.hara.pg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull --- Comment #7 from Kenji Hara <k.hara.pg@gmail.com> 2012-03-03 07:06:37 PST --- https://github.com/D-Programming-Language/dmd/pull/779 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 03, 2012 [Issue 7534] Allow attribute-overloading of an overridden method | ||||
---|---|---|---|---|
| ||||
Posted in reply to timon.gehr@gmx.ch | http://d.puremagic.com/issues/show_bug.cgi?id=7534 --- Comment #8 from Kenji Hara <k.hara.pg@gmail.com> 2012-03-03 07:12:16 PST --- (In reply to comment #6) > I think this is almost same as issue 3757 Sorry, the original issue is bug 3282, and bug 3757 depended on it. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 20, 2012 [Issue 7534] Allow attribute-overloading of an overridden method | ||||
---|---|---|---|---|
| ||||
Posted in reply to timon.gehr@gmx.ch | http://d.puremagic.com/issues/show_bug.cgi?id=7534 --- Comment #9 from github-bugzilla@puremagic.com 2012-03-19 23:10:42 PDT --- Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/12885a6cc408bfca83a89b99030697a187860781 Merge pull request #779 from 9rnsr/fix7534 Issue 7534 - Allow attribute-overloading of an overridden method -- 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