Thread overview | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
March 03, 2003 DMD 0.58 release | ||||
---|---|---|---|---|
| ||||
Maintenance. www.digitalmars.com/d/changelog.html |
March 03, 2003 Re: DMD 0.58 release | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | In article <b3vdgg$1f8t$1@digitaldaemon.com>, Walter says... > >Maintenance. > >www.digitalmars.com/d/changelog.html > <quote> Added covariant function return types </quote> Have you documented this anywhere? |
March 03, 2003 Re: DMD 0.58 release | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | Yeah, what is a covariant function return type? Sean "Walter" <walter@digitalmars.com> wrote in message news:b3vdgg$1f8t$1@digitaldaemon.com... > Maintenance. > > www.digitalmars.com/d/changelog.html |
March 03, 2003 Re: DMD 0.58 release | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean L. Palmer | "Sean L. Palmer" <seanpalmer@directvinternet.com> escreveu na mensagem news:b40568$1tur$1@digitaldaemon.com... > Yeah, what is a covariant function return type? > > Sean > > "Walter" <walter@digitalmars.com> wrote in message news:b3vdgg$1f8t$1@digitaldaemon.com... > > Maintenance. > > > > www.digitalmars.com/d/changelog.html You can redefine the return type to be "more specific". That means a subclass can override a inherited method and change the return type to a subtype of the original method. class A { A self() { return this; } } class B : A { B self() { // covariant return type return this; } } http://sern.ucalgary.ca/courses/SENG/609.03/W98/Abadi/AbadiCh2.html#2.6 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.459 / Virus Database: 258 - Release Date: 25/2/2003 |
March 03, 2003 Re: DMD 0.58 release | ||||
---|---|---|---|---|
| ||||
Posted in reply to Patrick Down | "Patrick Down" <Patrick_member@pathlink.com> wrote in message news:b404ce$1tff$1@digitaldaemon.com... > <quote> > Added covariant function return types > </quote> > > Have you documented this anywhere? Documentation? Huh? <g> www.digitalmars.com/d/function.html |
March 03, 2003 Re: DMD 0.58 release | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | In article <b3vdgg$1f8t$1@digitaldaemon.com>, Walter says... > >Maintenance. > >www.digitalmars.com/d/changelog.html > > " Added covariant function return types." Very cool! Yet another thing that is just plain broken in C++, fixed in D. Dan |
March 03, 2003 Re: DMD 0.58 release | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dan Liebgold | "Dan Liebgold" <Dan_member@pathlink.com> wrote in message news:b40b5v$21pv$1@digitaldaemon.com... > " Added covariant function return types." > > Very cool! Yet another thing that is just plain broken in C++, fixed in D. But C++ supports covariant function return types. Or is something broken about it that I'm missing? Oddly, C# does not support it, nor does Java. I'd intended to make this work in D for a while, I just was buried in other things. I've been looking at adding 'virtual types', too. |
March 03, 2003 Re: DMD 0.58 release | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | In article <b40d29$23a9$1@digitaldaemon.com>, Walter says... > >But C++ supports covariant function return types. Or is something broken about it that I'm missing? Oddly, C# does not support it, nor does Java. I'd intended to make this work in D for a while, I just was buried in other things. I've been looking at adding 'virtual types', too. > > Hmmm, I guess they slipped that in to the C++ design when I wasn't looking. Do you know when it was added? It seems to have been discussed as recently as a few years ago. Dan |
March 03, 2003 Re: DMD 0.58 release | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | Walter wrote:
> But C++ supports covariant function return types. Or is something broken about it that I'm missing? Oddly, C# does not support it, nor does Java. I'd intended to make this work in D for a while, I just was buried in other things. I've been looking at adding 'virtual types', too.
>
Both C# and Java plan to have 'em in future releases.
How would virtual types fit in with templates?
|
March 03, 2003 Re: DMD 0.58 release | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | In article <b3vdgg$1f8t$1@digitaldaemon.com>, Walter says... > >Maintenance. > >www.digitalmars.com/d/changelog.html > Are there plans to support initializing arrays with function literals, like this: //------------------------------------------------// typedef void function (char*) print_proc; print_proc functbl[4] = [ (print_proc)function void (char * text) { printf(" %s,\n", text); }, (print_proc)function void (char * text) { printf(" [%s],\n", text); }, (print_proc)function void (char * text) { printf("%s,\n", text); }, (print_proc)function void (char * text) { printf(" {%s},\n", text); }, ]; void test () { for (int i = 0; i < tbl.length; ++i) functbl[i]("nonsense"); } //------------------------------------------------// Currently, the compiler complains with "non-constant expression __anonymous". Perhaps its the above code has an error? This will work if I separate out the definitions of the functions and name them, then put the names in the array. Dan |
Copyright © 1999-2021 by the D Language Foundation