Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Delegation based OO
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-03-23 (08:51)
From: Correnson_Loïc <Loic.Correnson@t...>
Subject: Re: [Caml-list] Delegation based OO
This is a very interesting way of OO-programming.
More over, it allows to fullly benefit from multi-inheritance:

Suppose we have:
class type a = object ... end
class type b = object ... end

class a_and_b = object
    delegates [classtype to] a ;
    delegates [classtype to] b ;

I mainly found the requirement for such a delegation mechanism while looking
at GUI system, where classes have in general a *lot* of methods that must be
delgated by hand.

>From the compiler point of view, notice that such a delegation mechanism
would be  concistent with the one already existing for modules (and
functors) thanks to the "include" statement:

module type A = sig ... end
module type B = sig ... end
module A_and_B(mA : A)(mB : B) = struct
   include mA [ : A] ;
   include mB [ : B] ;

>From an academic point of view, and looking for a beautiful symetry between
objects and modules, such an delegation-based OO system would be a nice

    Loic Correnson.

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: