Re: Ensuring a method exists
- From: Pascal Costanza <pc@xxxxxxxxx>
- Date: Thu, 28 Sep 2006 08:44:49 +0200
Javier wrote:
Going on with this matter, and because I don't fully understand all the
answers you have done:
How would you implement an interface using CLOS with lots of different
methods? For example:
interface Collection {
void add (Object o);
void remove (Object o);
...
}
Tipically, your are going to implement lot of methods, say for example
10 or more.
The main reason for having an interface is that you are going to
provide classes based on it, and let the door open for the user to
implement new ones. So, if it doesn't make sense to implement them on
CLOS because Lisp resolves this problem in a different way, how is that
way? I mean, how is resolving Lisp this problem? Or, if CLOS doesn't
have this problem, why it doesn't?
In Java, interfaces are only necessary to make the static type system happy. When different classes offer similar functionality and you want to use their instances in the same place, they have to have the same type. So either, they are derived from the same common superclass, one is derived from the other, or they implement the same interface. Interface types are more flexible than class types because the former are not restricted to single inheritance. If Java classes would support multiple inheritance, interfaces would not be necessary, but abstract classes would be sufficient (like in C++).
Since Common Lisp is dynamically typed, you don't have to worry about all these things. When different classes offer functionality and you want to use their instances in the same place, you ... just use them.
Pascal
--
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/
.
- Follow-Ups:
- Re: Ensuring a method exists
- From: Javier
- Re: Ensuring a method exists
- From: Javier
- Re: Ensuring a method exists
- References:
- [CLOS] Ensuring a method exists
- From: Didier Verna
- Re: [CLOS] Ensuring a method exists
- From: Lars Rune Nøstdal
- Re: [CLOS] Ensuring a method exists
- From: Didier Verna
- Re: [CLOS] Ensuring a method exists
- From: Ken Tilton
- Re: [CLOS] Ensuring a method exists
- From: Christophe Rhodes
- Re: [CLOS] Ensuring a method exists
- From: Ken Tilton
- Re: [CLOS] Ensuring a method exists
- From: Pascal Costanza
- Re: [CLOS] Ensuring a method exists
- From: Ken Tilton
- Re: [CLOS] Ensuring a method exists
- From: Pascal Costanza
- Re: Ensuring a method exists
- From: Javier
- [CLOS] Ensuring a method exists
- Prev by Date: Re: [CLOS] Ensuring a method exists
- Next by Date: Re: lisp for webapps
- Previous by thread: Re: Ensuring a method exists
- Next by thread: Re: Ensuring a method exists
- Index(es):
Relevant Pages
|
|