Thread overview |
---|
April 10, 2007 [Issue 1120] New: old doc need updates: func sig changed to use anchored type | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=1120 Summary: old doc need updates: func sig changed to use anchored type Product: D Version: unspecified Platform: PC URL: http://digitalmars.com/d/operatoroverloading.html OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: www.digitalmars.com AssignedTo: bugzilla@digitalmars.com ReportedBy: someanon@yahoo.com Great improvement by introducing anchored type! thanks Walter! Please also update the doc, (I tried, it works) old doc: int opCmp(Object o); should be changed to: int opCmp(typeof(this) o); By default opCmp(anchored typed) is called; if it doesn't exist, then opCmp(Object o) is called. Same for opEquals. -- |
April 11, 2007 Re: [Issue 1120] New: old doc need updates: func sig changed to use anchored type | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | d-bugmail@puremagic.com napisaĆ(a): > http://d.puremagic.com/issues/show_bug.cgi?id=1120 > > Summary: old doc need updates: func sig changed to use anchored > type > Product: D > Version: unspecified > Platform: PC > URL: http://digitalmars.com/d/operatoroverloading.html > OS/Version: Linux > Status: NEW > Severity: normal > Priority: P2 > Component: www.digitalmars.com > AssignedTo: bugzilla@digitalmars.com > ReportedBy: someanon@yahoo.com > > > Great improvement by introducing anchored type! thanks Walter! > > Please also update the doc, (I tried, it works) > > old doc: > > int opCmp(Object o); > > should be changed to: > > int opCmp(typeof(this) o); > > By default opCmp(anchored typed) is called; if it doesn't exist, then > opCmp(Object o) is called. > > > Same for opEquals. > > "Nothing new under the sun" as says Book of Ecclesiastes. I didn't know that my proposition from thread "Covariance fix" (http://www.digitalmars.com/d/archives/digitalmars/D/Covariance_fix_was_Idea_Lazy_upcasting_51296.html) was already invented before and even has its name: "anchored types" :-) It seems that "anchored types" works, but not in full extent in D. My example still doesn't work (dmd 1.010): abstract class Storage { typeof(this) param1(int p1) { this.p1 = p1; return this; } private: int p1; } class SpecificStorage : Storage { public: typeof(this) param2(bool p2) { this.p2=p2; return this; } private: bool p2; } void main() { // ...ok... ...ok... ...ups! SpecificStorage s = (new SpecificStorage).param2(true).param1(5); } Implementing this will greatly simplify my program. :-) |
June 30, 2007 [Issue 1120] old doc need updates: func sig changed to use anchored type | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=1120 bugzilla@digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID ------- Comment #2 from bugzilla@digitalmars.com 2007-06-30 14:36 ------- Unfortunately, it has to be (Object o) or the derived opCmp won't override the base opCmp. -- |
Copyright © 1999-2021 by the D Language Foundation