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 KAA30959; Tue, 21 Sep 2004 10:48:49 +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 KAA31389 for ; Tue, 21 Sep 2004 10:48:47 +0200 (MET DST) Received: from oceanite.ens-lyon.fr (oceanite.ens-lyon.fr [140.77.1.22]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id i8L8mluT023637 for ; Tue, 21 Sep 2004 10:48:47 +0200 Received: from localhost (oceanite.ens-lyon.fr [127.0.0.1]) by oceanite.ens-lyon.fr (Postfix) with ESMTP id 85696320654 for ; Tue, 21 Sep 2004 10:47:48 +0200 (CEST) Received: from oceanite.ens-lyon.fr ([127.0.0.1]) by localhost (oceanite [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 03765-07 for ; Tue, 21 Sep 2004 10:47:48 +0200 (CEST) Received: from localhost.localdomain (ermitage.cri2000.ens-lyon.fr [140.77.13.63]) by oceanite.ens-lyon.fr (Postfix) with SMTP id 56C973202E9 for ; Tue, 21 Sep 2004 10:47:48 +0200 (CEST) Date: Tue, 21 Sep 2004 10:43:06 +0200 From: Damien Pous To: caml-list@inria.fr Subject: [Caml-list] Re: OCAML Downcasting? Message-Id: <20040921104306.0e472a0e@localhost.localdomain> In-Reply-To: <20040921.170339.118021840.garrigue@kurims.kyoto-u.ac.jp> References: <20040921.170339.118021840.garrigue@kurims.kyoto-u.ac.jp> X-Mailer: Sylpheed-Claws 0.9.12 (GTK+ 1.2.10; i386-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at ens-lyon.fr X-Miltered: at concorde with ID 414FEAEF.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; damien:01 damien:01 ens-lyon:01 downcasting:01 jacques:01 widget:01 widget:01 prerr:01 endline:01 ocamlc:01 ocamlc:01 ocaml:01 inherit:01 garrigue:01 garrigue:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hello, Jacques GARRIGUE wrote: > Just for fun, here is an example of the second approach: > > class virtual ['a] widget = object > method virtual raw : 'a > end > class ['a] button = object (self) > inherit ['a] widget > method raw = `Button self > method press = prerr_endline "pressed" > end How to write a signature for this code ? even "ocamlc -i" fails ! << #ocamlc -i error.ml class virtual ['a] widget : object method virtual raw : 'a end class ['a] button : object ('b) constraint 'a = [> `Button of 'b ] method press : unit method raw : 'a end >> then << #ocamlc -c error.ml The implementation error.ml does not match the interface error.cmi: Class declarations do not match: class ['a] button : object ('b) constraint 'a = [> `Button of 'b ] method press : unit method raw : 'a end does not match class ['a] button : object constraint 'a = [> `Button of 'a button ] method press : unit method raw : 'a end One type parameter has type [> `Button of < press : unit; raw : 'a; .. > as 'b ] as 'a but is expected to have type [> `Button of 'c button ] as 'c Type 'b is not compatible with type 'c button = < press : unit; raw : 'c > >> thanks, Damien ------------------- 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