Re: CLOS Properties Question
From: Antonio Menezes Leitao (Antonio.Leitao_at_evaluator.pt)
Date: 05/16/04
- Next message: Thomas Schilling: "Re: Closures: I'm not getting it"
- Previous message: Pascal Costanza: "Re: CLOS Properties Question"
- In reply to: Pascal Costanza: "Re: CLOS Properties Question"
- Next in thread: Pascal Costanza: "Re: CLOS Properties Question"
- Reply: Pascal Costanza: "Re: CLOS Properties Question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 16 May 2004 00:31:52 +0100
On Sat, 15 May 2004 21:12:57 +0200, Pascal Costanza wrote:
> [...]
> Java and C# have adopted a somewhat strange mixture of those imperative
> and declarative styles. In interfaces, you can declare methods, but you
> don't actually create them. However, you are not allowed to declare
> fields there, although that would have been perfectly reasonable. A
> field declaration in an interface could just have led to the requirement
> that such a field should exist in any class that declares to implement
> such an interface. This mess was the result of the fact that interfaces
> in Java just evolved from pure abstract classes in the C++ sense. There
> is even an OOPSLA or ECOOP paper published before the advent of Java
> that just describes the idiomatic use of pure abstract classes as
> interfaces in C++, together with the claim that the only reasonable use
> of multiple inheritance is to inherit from one non-abstract and zero or
> more purely abstract superclasses. That's just what the Java designers
> adopted, without thinking deeply enough about the consequences. (And
> this is in fact one of the best indications that C# is just a bad copy
> of Java, because they also just adopted Java's design decisions, with
> only some superficial syntactic sugar added, but without going
> significantly deeper.)
>
> Back to the question what this all has to do with multiple inheritance:
> If interfaces in Java and C# allowed for field declaration, roughly as
> described above, then you would indeed have a first step for a
> reasonable design for proper multiple inheritance. But that would just
> be another instance of Greenspun's tenth rule. Specifically, I disagree
> that C# properties are good solution to a well-understood problem.
I suggest you take a look at Linj, the Lisp to Java translator. Linj
implements a poor's man approach to multiple inheritance based on the idea
of mixins: you inherit from one base class and any number of mixins.
Mixins are classes that inherit from other mixins and that can't be
instantiated but, other than that, they don't have limitations: you can
define slots and/or methods just like in normal classes. When these
mixins are translated into Java interfaces they loose the non-constant
slots and the methods become abstract (loosing their bodies). However,
classes that inherit from the mixin will get copies of the remaining slots
slots and of the methods.
It can lead to code bloat, of course, but it's much better than doing code
bloat by hand, humm, I mean, copy & paste :-)
Antonio Leitao.
- Next message: Thomas Schilling: "Re: Closures: I'm not getting it"
- Previous message: Pascal Costanza: "Re: CLOS Properties Question"
- In reply to: Pascal Costanza: "Re: CLOS Properties Question"
- Next in thread: Pascal Costanza: "Re: CLOS Properties Question"
- Reply: Pascal Costanza: "Re: CLOS Properties Question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|