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/


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user

Reply via email to