www.digitalmars.com         C & C++   DMDScript  

D - Partial implementation of Interfaces (again)

reply "Andres Rodriguez" <rodriguez ai.sri.com> writes:
This is one of the main issues that stand between me and using
the language for more serious work.  I believe it is a huge problem
for developing OO programs.  I have not seen any resolution
coming out of the previous thread, so I am posting it again.  And
I am willing to settle for "this will get resolved at an undetermined
point in the future", but uncertainty on uncertainty is bad.

Cheers,

Andres
Feb 25 2004
next sibling parent reply Russ Lewis <spamhole-2001-07-16 deming-os.org> writes:
Andres Rodriguez wrote:
 This is one of the main issues that stand between me and using
 the language for more serious work.  I believe it is a huge problem
 for developing OO programs.  I have not seen any resolution
 coming out of the previous thread, so I am posting it again.  And
 I am willing to settle for "this will get resolved at an undetermined
 point in the future", but uncertainty on uncertainty is bad.
 
 Cheers,
 
 Andres

I too think that this is an important feature. However, I think it is part of a larger feature set we need. We need something that gives us something like C++ double inheritance (where you can actually source functionality & member data from multiple sources), but without all of the complexities of C++ double inheritance. So my argument is that we need a more general solution that would give use partial implementation on interfaces AND everything else.
Feb 25 2004
parent reply "Andres Rodriguez" <rodriguez ai.sri.com> writes:
I see what you are saying, but at this point I settle for less.  And I
would be interested in your views about how to achieve "C++ double
inheritance (...) but without all of  the complexities of C++ double
inheritance".
Within all my ignorance, I see that goal hard to achieve.  I have heard
marvelous things about Eiffel multiple inheritance but don't know
much about it.


"Russ Lewis" <spamhole-2001-07-16 deming-os.org> wrote in message
news:c1in5d$2j02$1 digitaldaemon.com...
 Andres Rodriguez wrote:
 This is one of the main issues that stand between me and using
 the language for more serious work.  I believe it is a huge problem
 for developing OO programs.  I have not seen any resolution
 coming out of the previous thread, so I am posting it again.  And
 I am willing to settle for "this will get resolved at an undetermined
 point in the future", but uncertainty on uncertainty is bad.

 Cheers,

 Andres

I too think that this is an important feature. However, I think it is part of a larger feature set we need. We need something that gives us something like C++ double inheritance (where you can actually source functionality & member data from multiple sources), but without all of the complexities of C++ double inheritance. So my argument is that we need a more general solution that would give use partial implementation on interfaces AND everything else.

Feb 25 2004
parent Russ Lewis <spamhole-2001-07-16 deming-os.org> writes:
I've wondered about using templates to achieve multiple-inheritance like 
things.  You can do this with existing D, but it's really hackish:

FYI: I haven't tested this code...I'm just writing off the top of my head...



interface Foo {
	void foo1();
	void foo2();
}
class Foo_Implementation(Base) : Base, /*implements*/ Foo {
	void foo1() { ... }
	void foo2() { ... }
}

class Bar {
	void bar1();
	void bar2();
}
class ChildOf_Bar_and_Foo : Foo_Implementation!(Bar) {
	/* override whatever you want */
}

/* These assignments should be valid...right? */
Foo foo = new ChildOf_Bar_and_Foo();
Bar bar = new ChildOf_Bar_and_Foo();



So, you have a class (ChildOf_Bar_and_Foo) which contains all of the 
members of Bar and FooImplementation.  Likewise, you have Foo, which is 
really an interface, but we can pretend that it is a 2nd base class.

BTW, you should be able to create a "child class of Foo" like this:



interface ChildOfFoo {
	void foo1();
	void foo2();
	void foo3();	/* new field */
}
class ChildOfFooImplementation(Base) : Foo!(Base), /*implements*/ 
ChildOfFoo {
	void foo1() {
		/* this is necessary since Walter doesn't support
		 * partial implementation of interfaces
		 */
		super.foo1();
	}
	void foo2() { ... }	/* overrides Foo!(Base) */
	void foo3() { ... }	/* new to ChildOfFoo */
}



Andres Rodriguez wrote:
 I see what you are saying, but at this point I settle for less.  And I
 would be interested in your views about how to achieve "C++ double
 inheritance (...) but without all of  the complexities of C++ double
 inheritance".
 Within all my ignorance, I see that goal hard to achieve.  I have heard
 marvelous things about Eiffel multiple inheritance but don't know
 much about it.
 
 
 "Russ Lewis" <spamhole-2001-07-16 deming-os.org> wrote in message
 news:c1in5d$2j02$1 digitaldaemon.com...
 
Andres Rodriguez wrote:

This is one of the main issues that stand between me and using
the language for more serious work.  I believe it is a huge problem
for developing OO programs.  I have not seen any resolution
coming out of the previous thread, so I am posting it again.  And
I am willing to settle for "this will get resolved at an undetermined
point in the future", but uncertainty on uncertainty is bad.

Cheers,

Andres

I too think that this is an important feature. However, I think it is part of a larger feature set we need. We need something that gives us something like C++ double inheritance (where you can actually source functionality & member data from multiple sources), but without all of the complexities of C++ double inheritance. So my argument is that we need a more general solution that would give use partial implementation on interfaces AND everything else.


Feb 27 2004
prev sibling next sibling parent "Kris" <someidiot earthlink.net> writes:
I do wish Walter would clarify the reasoning behind this seemingly
artificial constraint. A partial interface-implementation would stipulate
the implementing class be declared 'abstract', and abstract classes are
supported so ...

My view on this is perhaps simplistic, but clarification would certainly
help everyone move on <g>

How about weighing-in on this one Walter?

- Kris



"Andres Rodriguez" <rodriguez ai.sri.com> wrote in message
news:c1iiur$2bd6$1 digitaldaemon.com...
 This is one of the main issues that stand between me and using
 the language for more serious work.  I believe it is a huge problem
 for developing OO programs.  I have not seen any resolution
 coming out of the previous thread, so I am posting it again.  And
 I am willing to settle for "this will get resolved at an undetermined
 point in the future", but uncertainty on uncertainty is bad.

 Cheers,

 Andres

Feb 25 2004
prev sibling parent reply Sam McCall <tunah.d tunah.net> writes:
This has been fixed in the development version, so I guess we have to 
wait for the next release. Much appreciated Walter, but now we're just 
going to bug you for a release ;)
Sam

-------- Original Message --------
Subject: Re: DMD 0.79 Crash (templates, abstract classes, inheritance)
Date: Tue, 24 Feb 2004 22:14:15 -0800
From: Walter <walter walterbright.com>
To: Sam McCall <tunah.d tunah.net>
References: <c0ahak$q3a$1 digitaldaemon.com>

The following works:

interface Interface(T)
{
     void foo();
}

void bar(Interface!(Object) i)
{
     i.foo();
}

class Abstract(T) : Interface!(T)
{
     abstract void foo();
}

class Concrete(T) : Abstract!(T)
{
     void foo() { printf("Concrete.foo(this = %p)\n", this); }
}

class Sub(T) : Concrete!(T)
{
}

int main()
{
     Sub!(Object) s = new Sub!(Object)();
     s.foo();
     bar(s);
     return 0;
}
Feb 25 2004
parent reply "Kris" <someidiot earthlink.net> writes:
Yay! And there was great rejoicing!

Thank-you Sam and Walter.


"Sam McCall" <tunah.d tunah.net> wrote in message
news:c1jc74$m7m$1 digitaldaemon.com...
 This has been fixed in the development version, so I guess we have to
 wait for the next release. Much appreciated Walter, but now we're just
 going to bug you for a release ;)
 Sam

Feb 25 2004
next sibling parent "Andres Rodriguez" <rodriguez ai.sri.com> writes:
Indeed, those are great news.

"Kris" <someidiot earthlink.net> wrote in message
news:c1jdha$pa1$1 digitaldaemon.com...
 Yay! And there was great rejoicing!

 Thank-you Sam and Walter.


 "Sam McCall" <tunah.d tunah.net> wrote in message
 news:c1jc74$m7m$1 digitaldaemon.com...
 This has been fixed in the development version, so I guess we have to
 wait for the next release. Much appreciated Walter, but now we're just
 going to bug you for a release ;)
 Sam


Feb 25 2004
prev sibling parent Sam McCall <tunah.d tunah.net> writes:
Kris wrote:
 Yay! And there was great rejoicing!
 
 Thank-you Sam and Walter.

asked a question earlier. One day I'll have a look at the front end code ;) Sam
Feb 26 2004