Re: [CLOS] Ensuring a method exists
- From: Christophe Rhodes <csr21@xxxxxxxxx>
- Date: Wed, 27 Sep 2006 12:01:05 +0100
Ken Tilton <kentilton@xxxxxxxxx> writes:
Of course the big question no one will ask is why you want to do
this. Sounds like bad design. But you are not alone, we get people
wanting to do this almost as often as we get people trying to fix the
parens.
I'm not so certain that this kind of thing is necessarily bad design.
I think that CLOS's generic functions and class inheritance provide
good ways of adding functionality ("extending", if you will) by
subclassing; what I think is harder to express in vanilla CLOS is
removal of invariants, or generalization of functionality.
To take a concrete example, consider implementing a data structure
such as an R-tree, which has a relatively complex set of invariants
that you might want to assert are true at various points in the
protocol. Then you implement a variant, such as the R*-tree, which
obeys the same protocol, and indeed shares much of the implementation,
but has slightly different (but overlapping) invariants. How do you
model that, with just CLOS? Probably what you do is define some kind
of abstract base class and make R-trees and R*-trees inherit from that
base class, but now you can't share the methods that actually should
be shared: instead you have to implement the methods separately,
admittedly maybe with a call to the same function. So sometimes I
think it makes sense to want to treat direct instances and general
instances of a class differently: it allows you to express things in a
way that is closer to the application space (which is what we're
aiming for, right?)
I believe this is the kind of thing that beta's inner() was invented
to help in modelling; there are various claims around that it helps
with extensible GUI hierarchies (see e.g. Goldberg, Findler and Flatt,
"Super and Inner -- Together at Last!").
Christophe
.
- Follow-Ups:
- Re: [CLOS] Ensuring a method exists
- From: Ken Tilton
- Re: [CLOS] 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
- [CLOS] Ensuring a method exists
- Prev by Date: Re: Compiling Lisp
- Next by Date: Re: High accuracy timer?
- Previous by thread: Re: [CLOS] Ensuring a method exists
- Next by thread: Re: [CLOS] Ensuring a method exists
- Index(es):
Relevant Pages
|
|