caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Didier Remy <Didier.Remy@inria.fr>
To: james woodyatt <jhw@wetware.com>
Cc: The Trade <caml-list@inria.fr>
Subject: Re: [Caml-list] functional objects
Date: Mon, 21 Oct 2002 08:55:02 +0200	[thread overview]
Message-ID: <20021021085502.A9551@morgon.inria.fr> (raw)
In-Reply-To: <FD5752D0-E4AA-11D6-B6CD-000393BA7EBA@wetware.com>; from jhw@wetware.com on Sun, Oct 20, 2002 at 09:10:09PM -0700

> What would that look like in the multiple inheritance case?

Why did you not ask this in the first place? (i.e. if you meant 
multiple inheritance, you should have provided an example with multiple
inheritance). 

Have you really tried this exercise yourself before asking for help?  The
pattern seemed simple enough so that its generalization was obvious.

Didier Rémy


    class ['a1] c1 (x1 : 'a1) = object
      val x1_ = x1
      method m1 = ()
      method c1 x1 = {< x1_ = x1 >}
    end;;

    class ['a2] c2 (x2 : 'a2) = object
      val x2_ = x2
      method m2 = ()
      method c2 x2 = {< x2_ = x2 >}
    end;;

    class ['a1,'a2, 'a3] c3 x1 x2 (x3 : 'a3) = object
      inherit ['a1] c1 x1
      inherit ['a2] c2 x2
      val x3_ = x3
      method m3 = ()
      method c3 x1 x2 x3 = ({< x3_ = x3 >} # c1 x1) # c2 x2
    end;;

(* Note that fields are overriden in the reverse order, which does not
matter since they are all disjoint. Should method c1 and c2 both override
the same parent field, then the order should be enforced, as follows: *)

    class ['a1,'a2, 'a3] c3 x1 x2 (x3 : 'a3) = object (self)
      inherit ['a1] c1 x1
      inherit ['a2] c2 x2
      val x3_ = x3
      method m3 = ()
      method private c3_ x3 = {< x3_ = x3 >} 
      method c3 x1 x2 x3 = ((self # c1 x1) # c2 x2) # c3_ x3
    end;;


-------------------
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


  reply	other threads:[~2002-10-21  6:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-19  0:54 james woodyatt
2002-10-19 20:48 ` Didier Remy
2002-10-21  4:10   ` james woodyatt
2002-10-21  6:55     ` Didier Remy [this message]
2002-10-21 18:40       ` james woodyatt
2002-10-22  8:42         ` Didier Remy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20021021085502.A9551@morgon.inria.fr \
    --to=didier.remy@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=jhw@wetware.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).