[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: base class parameterisation?
From: |
Andy Wingo |
Subject: |
Re: base class parameterisation? |
Date: |
Tue, 12 Jun 2007 22:50:02 +0200 |
Hi Marco,
On Sat, 2007-06-09 at 08:18 +0200, Marco Maggi wrote:
> ---A---
> | |
> v v
> A1 A2
>
> B
>
> I wonder if there is a way to parameterise the construction
> of 'B' to let it have 'A1' or 'A2' as base class. I do not
> want to use delegation.
I suspect you will have to make a metaclass and specialize on
allocate-instance. Something like (my GOOPS is rusty):
(define-class A-metaclass (<class>))
(define-method (allocate-instance (class A-metaclass) initargs)
(if (random-predicate) (allocate-instance A1) (allocate-instance A2)))
(define-class B () #:metaclass A-metaclass ..)
Good luck,
Andy.
--
http://wingolog.org/