English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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 caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners