Re: Is it possible to remove a slot when inheriting?
- From: Jules <julesjacobs@xxxxxxxxx>
- Date: 15 May 2007 12:34:05 -0700
On May 15, 8:16 pm, Joe Marshall <eval.ap...@xxxxxxxxx> wrote:
On May 15, 7:24 am, Pedro Kroger <pedro.kro...@xxxxxxxxx> wrote:
Hi,
suppose I have a class with 6 slots, is it possible to inherit that
class except for one slot? for instance, if I have foo like this:
(defclass foo ()
(a1 a2 a3 a5 a5 a6))
and bar is a subclass of foo:
(defclass bar (foo)
...)
foo will have, of course, the 6 slots, but I want bar to have all
slots of foo except a6. I don't have any specific use for this, I'm
just thinking if this is possible or not. (I don't even know if this
is good practice)
This is an instance of `subtractive inheritance'. CLOS doesn't
support it by default (but you can always change that).
It's probably not a good idea because if BAR inherits from FOO, then a
BAR object should be usable as a FOO. If the BAR object doesn't have
an a6 slot, then it is likely to not work for certain methods.
Consider a rectangle inheriting from polygon. You want to keep a list
of points in polygon, but you want width/height, x/y slots in
rectangle. You define an accessor method `points` that computes the
list of points for rectangles.
Jules
.
- Follow-Ups:
- Re: Is it possible to remove a slot when inheriting?
- From: Dan Bensen
- Re: Is it possible to remove a slot when inheriting?
- From: John Thingstad
- Re: Is it possible to remove a slot when inheriting?
- References:
- Is it possible to remove a slot when inheriting?
- From: Pedro Kroger
- Re: Is it possible to remove a slot when inheriting?
- From: Joe Marshall
- Is it possible to remove a slot when inheriting?
- Prev by Date: How do you set the load path?
- Next by Date: Re: macro for shorter array syntax
- Previous by thread: Re: Is it possible to remove a slot when inheriting?
- Next by thread: Re: Is it possible to remove a slot when inheriting?
- Index(es):
Relevant Pages
|