Re: Former C++ Programmer Approaches Lisp



Carl Shapiro <cshapiro+spam@xxxxxxxxx> writes:

>
> Kenny Tilton <ktilton@xxxxxxxxxx> writes:
>
> > Interfaces are OOPs' way of saying "Sh*t, we acknowledge the need for
> > multiple inheritance but this is as close as we can get. Hope ya like
> > it!"
>
> I think this is an overly simplistic way to view interfaces. You can
> get yourself into trouble with CLOS if you define a class which
> multiply inherits super classes which have conflicting slots. This
> situation is exacerbated if, for example, the slots have different
> allocation policies. Interfaces compromise by not allowing state to
> be multiply inherited. This compromise is not without merit.

Well, with proper use of namespaces and naming discipline, this is not
supposed to happen. (Yeah, in practice it doesn't always work that
way), but the philosophy is that a slot named by a particular symbol is
supposed to have only one meaning. So one would really ideally have
something like ship:deck and card:deck to differentiate slots that would
otherwise have similar names.

The drawback to interfaces is that if you ever want an interface that
needs to have state, then you have to make sure you add the slots for
that state into your object. And in Java it is even worse, because
interfaces can only contain abstract methods. Which means you have to
implement all the methods for an interface whenever you want to include
it for inheritance. This is not only annoying, but it removes a lot of
the benefit of using OOP in the first place.

--
Thomas A. Russ, USC/Information Sciences Institute

.



Relevant Pages

  • Re: Java Feature Proposal
    ... > conflict. ... No, there is no naming conflict with Java interfaces, since they contain ... class to inherit multiple conflicting implementations of a method. ... I don't see why multiple inheritance of fields is any more of a problem ...
    (comp.lang.java.programmer)
  • Re: Former C++ Programmer Approaches Lisp
    ... multiple inheritance but this is as close as we can get. ... I think this is an overly simplistic way to view interfaces. ... Interfaces compromise by not allowing state to ... all to achieve an artificial discipline saving us ...
    (comp.lang.lisp)
  • Re: Java Feature Proposal
    ... implementation of interfaces. ... multiple inheritance of fields which was the only big problem of [poorly ... > classes can provide the same functionality as you're proposing. ... Yes abstract base classes could be used similarly except that you can't have ...
    (comp.lang.java.programmer)
  • Re: Former C++ Programmer Approaches Lisp
    ... > multiple inheritance but this is as close as we can get. ... I think this is an overly simplistic way to view interfaces. ... multiply inherits super classes which have conflicting slots. ... Interfaces compromise by not allowing state to ...
    (comp.lang.lisp)
  • Re: IDropSource and IDataObject Multiple Inheritance
    ... COM does not support multiple inheritance for interfaces. ... apartment model of the object and the apartment model of the ... One of this is invoked by ActiveXContainer and anothere by WindowsShell. ...
    (microsoft.public.win32.programmer.ole)