[Issue 1120] New: old doc need updates: func sig changed to use anchored type

Aarti_pl aarti at interia.pl
Wed Apr 11 00:22:01 PDT 2007


d-bugmail at 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 at digitalmars.com
>         ReportedBy: someanon at 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. :-)


More information about the Digitalmars-d-bugs mailing list