From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id D4368BB9C for ; Thu, 15 Sep 2005 23:25:12 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j8FLPCFx012020 for ; Thu, 15 Sep 2005 23:25:12 +0200 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id XAA26681 for ; Thu, 15 Sep 2005 23:25:11 +0200 (MET DST) Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.199]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j8FLPASE000758 for ; Thu, 15 Sep 2005 23:25:11 +0200 Received: by zproxy.gmail.com with SMTP id f1so144159nzc for ; Thu, 15 Sep 2005 14:25:10 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=r+ZyGlDfg5PYFjonxNbvEdIEd1/ImnLNZqtIgICHS6Iyaj1e7b0y+/NTpKrOam9UpIxDfSkexU5ve3W8Vg/KtXAaKovTk+Bj5jHIzy3zW/j00GI13hgFR0fsRU5YHdHTAu4mIG5imZvCBAaTitfaEnIw7A5FJdqiLeh9ZOSbODs= Received: by 10.36.177.9 with SMTP id z9mr1617212nze; Thu, 15 Sep 2005 14:25:10 -0700 (PDT) Received: by 10.36.80.3 with HTTP; Thu, 15 Sep 2005 14:25:10 -0700 (PDT) Message-ID: Date: Thu, 15 Sep 2005 14:25:10 -0700 From: "Corey O'Connor" Reply-To: coreyoconnor@gmail.com To: david.baelde@ens-lyon.org Subject: Re: [Caml-list] Heritage Cc: caml-list@inria.fr In-Reply-To: <53c6559205091513486a10b481@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <53c6559205091513486a10b481@mail.gmail.com> X-Miltered: at concorde with ID 4329E6B8.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 4329E6B6.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 runtime:01 decorator:01 runtime:01 buffer:01 lexing:01 buf:01 buf:01 token:01 buffer:01 caml-list:01 beginner's:01 ocaml:01 beginners:01 bug:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_BY_IP autolearn=disabled version=3.0.3 For something that provides the functionality of runtime inheritance check out the Decorator pattern. http://www.dofactory.com/Patterns/PatternDecorator.aspx Essentially the deccorator pattern is like this: * All decorators conform to the same interface of the object they are decorating. * Methods follow this pattern: (In C++) type CMyDecorator::SomeMethod(args) { // Do some additional stuff return mObjectBeingDecorated.SomeMethod(args); } The end result is you can add functionality to methods of an object at runt= ime. Hope that helps, -Corey O'Connor On 9/15/05, David Baelde wrote: > Hi list, >=20 > We're getting crazy with some design problem. We need to design a > buffer object and be able to extend it with some features > (lexing,color highlighting... yes we're working on an editor). Here's > the problem. >=20 > I'd like to have a class (or function) for every extension. For > example be able to write > new parsed (new lexed (new basic)). I.e. I would need the class: >=20 > class lexed buf =3D > object inherit buf method get_token =3D ... end >=20 > It doesn't work cause inheritance is only from classes, not objects. > But I want buf to be of any class (any super-class of buffer actually) > but I don't want to coerce buf to type buffer, cause I want to keep > extra methods if any were added. >=20 > I'd like to know if there's any simple example of why > object-inheritance is forbidden, and if any of you have an idea for > that problem.. >=20 > Thanks. > -- > David >=20 > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs >=20 --=20 -Corey O'Connor