[D.typesystem] Suggestion for improving OO inheritance models

2010-09-01 Thread Justin Johansson
Whilst one admirable aspiration of D is to make for better meta-programming capability in a PL, IMHO one seemingly-lacking aspiration of D is in the area of improving OO inheritance models over and above that provisioned for in C++ and Java. Maybe I'm ill-informed though I'd say that D, C++ and J

Re: [D.typesystem] Suggestion for improving OO inheritance models

2010-09-01 Thread retard
Wed, 01 Sep 2010 23:16:15 +0930, Justin Johansson wrote: > Whilst one admirable aspiration of D is to make for better > meta-programming capability in a PL, IMHO one seemingly-lacking > aspiration of D is in the area of improving OO inheritance models over > and above that provisioned for in C++ a

Re: [D.typesystem] Suggestion for improving OO inheritance models

2010-09-01 Thread Philippe Sigaud
On Wed, Sep 1, 2010 at 18:13, retard wrote: > > Have you taken a loot at Scala & traits already? It would be a great > starting point. > Scala's traits are great! Implicits in Scala are quite interesting too. Also, Haskell typeclasses I wonder if D can have part of Scala traits functionality wi

Re: [D.typesystem] Suggestion for improving OO inheritance models

2010-09-01 Thread Jacob Carlborg
On 2010-09-01 22:44, Philippe Sigaud wrote: On Wed, Sep 1, 2010 at 18:13, retard wrote: Have you taken a loot at Scala & traits already? It would be a great starting point. Scala's traits are great! Implicits in Scala are quite interesting too. Also, Haskell typeclasses I wonder if

Re: [D.typesystem] Suggestion for improving OO inheritance models

2010-09-01 Thread Andrej Mitrovic
You mean like this?: module add_virtual_functions; import std.stdio : writeln; void main() { test(); } mixin template Foo() { void func() { writeln("Foo.func()"); } } class Bar { void func() { writeln("Bar.func()"); } } class Code : Bar { mixin F

Re: [D.typesystem] Suggestion for improving OO inheritance models

2010-09-01 Thread Andrej Mitrovic
Disregard the module name declaration. The original example had the template mixin create a virtual method, and then you can override it in the inheriting class. On Wed, Sep 1, 2010 at 11:39 PM, Andrej Mitrovic wrote: > You mean like this?: > module add_virtual_functions; > > import std.stdio : w

Re: [D.typesystem] Suggestion for improving OO inheritance models

2010-09-01 Thread Andrej Mitrovic
Ah nevermind. I didn't realize you've said "overload". On Wed, Sep 1, 2010 at 11:39 PM, Andrej Mitrovic wrote: > You mean like this?: > module add_virtual_functions; > > import std.stdio : writeln; > > void main() > { >    test(); > } > > mixin template Foo() > { >    void func() >    { >        

Re: [D.typesystem] Suggestion for improving OO inheritance models

2010-09-01 Thread retard
Wed, 01 Sep 2010 23:30:08 +0200, Jacob Carlborg wrote: > On 2010-09-01 22:44, Philippe Sigaud wrote: >> On Wed, Sep 1, 2010 at 18:13, retard wrote: >> >> >> Have you taken a loot at Scala & traits already? It would be a >> great starting point. >> >> >> Scala's traits are great! Implicits

Re: [D.typesystem] Suggestion for improving OO inheritance models

2010-09-01 Thread Andrei Alexandrescu
On 9/1/10 16:56 CDT, retard wrote: Wed, 01 Sep 2010 23:30:08 +0200, Jacob Carlborg wrote: On 2010-09-01 22:44, Philippe Sigaud wrote: On Wed, Sep 1, 2010 at 18:13, retard wrote: Have you taken a loot at Scala& traits already? It would be a great starting point. Scala's traits a

Re: [D.typesystem] Suggestion for improving OO inheritance models

2010-09-02 Thread Jacob Carlborg
On 2010-09-01 23:39, Andrej Mitrovic wrote: You mean like this?: module add_virtual_functions; import std.stdio : writeln; void main() { test(); } mixin template Foo() { void func() { writeln("Foo.func()"); } } class Bar { void func() { writeln(

Re: [D.typesystem] Suggestion for improving OO inheritance models

2010-09-02 Thread Andrej Mitrovic
Yeah, my mistake. I missread your post. :) But, you can use mixin expressions to add overloaded methods. E.g.: import std.stdio; class Bar { void func() { writeln("Bar.func()"); } mixin("void func(string x) { writeln(x); }"); } void main() { Bar bar = new Bar; b