[plt-scheme] Re: Multiple inheritance problem with mixins

From: Daniel Pinto de Mello e Silva (daniel.silva at gmail.com)
Date: Wed Feb 2 22:55:14 EST 2005

Nevermind :)

(define sm<%>
   (interface () get-expansion set-expansion))

(define (shared-mixin %)
  (if (implementation? % sm<%>)
      %
     (class %
        (super-new)
        (define/public (set-expansion x) (void))
        (define/public (get-expansion) (void)))))


Daniel


On Thu, 3 Feb 2005 12:44:21 +0900, Daniel Pinto de Mello e Silva
<daniel.silva at gmail.com> wrote:
> Hi,
> I have some shared functionality between two mixins that shouldn't
> know about each other.  I wanted to implement the shared functionality
> as another mixin, but I get an error:
> class*: superclass already contains method: m for class: stdin::57
> 
> Is there a good way to abstract out shared functionality from two
> mixins?  This is the distilled example:
> 
> (require (lib "class.ss"))
> 
> (define (shared-mixin %)
>   (class %
>      (super-new)
>      (define/public (set-expansion x) (void))
>      (define/public (get-expansion) (void))))
> 
> (define (tab-completion %)
>   (class (shared-mixin %)
>      (super-new)
>      (inherit set-expansion get-expansion)))
> 
> (define (online-error-reporting %)
>   (class (shared-mixin %)
>      (super-new)
>      (inherit set-expansion get-expansion)))
> 
> (define the-class% (online-error-reporting (tab-completion object%)))
> 
> 
> Daniel
>



Posted on the users mailing list.