[plt-scheme] class.ss inheritance

From: Robby Findler (robby at cs.uchicago.edu)
Date: Tue Mar 18 21:36:31 EST 2003

I think that what you want are mixins. They are functions that consume
a class and produce a class derived from the input, like this:

  (define (a-mixin %)
    (class %

So, each of the (what would be) multiply inherited classes is defined
this way and then you compose them together afterwards. See the
framework manual for some helpful macros (this should probably move
somewhere else at some point).

For more a more detailed overview, there are two papers of interest.
The first is about a use of mixins (and probably most immediately
helpful). The second is the formal underpinnings of mixins and an
explanation of how to add them to Java.



At Tue, 18 Mar 2003 21:13:33 -0500, "Neil W. Van Dyke" wrote:
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> In absence of multiple-inheritance in class.ss, I'm using interfaces
> with composition and manual delegation for some of the is-a
> relationships, such for the server-authority-haver<%>:
>     (define http-uri%
>       (class* hierarchical-uri% (server-authority-haver<%>)
>         (field server-authority [...])
>         (define/public (get-user) (send server-authority get-user))
>         (define/public (get-host) (send server-authority get-host))
>         (define/public (get-portnum)
>           (send server-authority get-portnum/default 80))
>         [...]))
> With MI, I'd do something more like:
>     (define http-uri%
>       (class* (hierarchical-uri% server-authority-uri%) ()
>         (define/override (default-portnum) 80)
>         [...]))
> Are there any class.ss tricks for doing something closer to the latter
> example, such as a tricky way of approximating MI, or some convenience
> for delegation?
> -- 
>                                              http://www.neilvandyke.org/

Posted on the users mailing list.