From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA06987; Thu, 21 Aug 2003 18:41:53 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id SAA18727 for ; Thu, 21 Aug 2003 18:41:52 +0200 (MET DST) Received: from mwinf0204.wanadoo.fr (smtp7.wanadoo.fr [193.252.22.29]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h7LGfpf29902 for ; Thu, 21 Aug 2003 18:41:51 +0200 (MET DST) Received: from debian (ca-bordeaux-16-155.w80-8.abo.wanadoo.fr [80.8.88.155]) by mwinf0204.wanadoo.fr (SMTP Server) with ESMTP id 0FFD1A000113 for ; Thu, 21 Aug 2003 18:41:51 +0200 (CEST) Received: from moi by debian with local (Exim 3.36 #1 (Debian)) id 19psVb-0001wt-00 for ; Thu, 21 Aug 2003 18:41:59 +0200 To: caml-list@inria.fr Subject: Re: [Caml-list] does class polymorphism need to be so complicated? References: <3F43E250.1040903@socialtools.net> <20030821092849B.garrigue@kurims.kyoto-u.ac.jp> <3F448015.8090106@socialtools.net> <20030821175808V.garrigue@kurims.kyoto-u.ac.jp> <3F449301.8050500@socialtools.net> <873cfvz148.dlv@wanadoo.fr> <20030821131121.GA30240@redhat.com> From: Remi Vanicat Mail-Copy-To: never Date: Thu, 21 Aug 2003 18:41:59 +0200 In-Reply-To: <20030821131121.GA30240@redhat.com> (Richard Jones's message of "Thu, 21 Aug 2003 14:11:21 +0100") Message-ID: <87y8xnx8rs.dlv@wanadoo.fr> User-Agent: Gnus/5.090024 (Oort Gnus v0.24) Emacs/21.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 8bit X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 foo:01 foo:01 dept-info:01 labri:01 labri:01 u-bordeaux:01 u-bordeaux:01 0200,:01 writes:01 writes:01 remi:01 remi:01 vanicat:01 vanicat:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Richard Jones writes: > On Thu, Aug 21, 2003 at 01:44:23PM +0200, Remi Vanicat wrote: >> Benjamin Geer writes: >> > class type virtual printer = object >> > method virtual print : #printable -> unit >> > end ;; >> > >> > class type virtual talker = object >> > method virtual talk : #printable -> unit >> > end ;; >> > >> > class my_printer_talker () = object (self : #printer; #talker) >> > method print obj = (* ... *) >> > method talk obj = (* ... *) >> > end ;; >> >> well this work : >> >> class my_printer_talker () = object (self : 's) >> constraint 's = #printer >> constraint 's = #talker >> method print obj = (* ... *) >> method talk obj = (* ... *) >> end ;; > > Is there a way to add extra methods to my_printer_talker? Yes. Add them. the constraint 's = #foo only say that the current class must have at least the method specified in foo, and with the the type specified in foo. but you can still make the type grow. -- Rémi Vanicat vanicat@labri.u-bordeaux.fr http://dept-info.labri.u-bordeaux.fr/~vanicat ------------------- 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