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 LAA02146; Tue, 21 Sep 2004 11:50:02 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 LAA02839 for ; Tue, 21 Sep 2004 11:50:00 +0200 (MET DST) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id i8L9nhiU024702 for ; Tue, 21 Sep 2004 11:49:44 +0200 Received: from localhost (suiren.kurims.kyoto-u.ac.jp [130.54.16.25]) by kurims.kurims.kyoto-u.ac.jp (8.9.3p2-20030924/3.7W) with ESMTP id SAA27274; Tue, 21 Sep 2004 18:49:34 +0900 (JST) Date: Tue, 21 Sep 2004 18:49:34 +0900 (JST) Message-Id: <20040921.184934.41232635.garrigue@kurims.kyoto-u.ac.jp> To: skaller@users.sourceforge.net Cc: caml-list@inria.fr Subject: Re: [Caml-list] Re: OCAML Downcasting? From: Jacques GARRIGUE In-Reply-To: <1095758974.2580.859.camel@pelican.wigram> References: <20040921104306.0e472a0e@localhost.localdomain> <20040921.181531.71542839.garrigue@kurims.kyoto-u.ac.jp> <1095758974.2580.859.camel@pelican.wigram> X-Mailer: Mew version 4.0.64 on Emacs 21.2 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 414FF937.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 downcasting:01 jacques:01 sourceforge:01 2004:99 jacques:01 widget:01 prerr:01 endline:01 incompatible:01 strangely:01 bug:01 ocaml:01 inherit:01 variants:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk From: skaller > On Tue, 2004-09-21 at 19:15, Jacques GARRIGUE wrote: > > > class ['a] button = object (self) > > inherit ['a] widget > > method raw = `Button (self :> 'a button) > > method press = prerr_endline "pressed" > > end > > > Without the self-cast, you cannot extend any class. > > Is that an issue with classes or polymorphic variants? With classes. If you omit the coercion, any class inheriting from button would have the type of the raw method specialized to itself, and as a result it would be incompatible with button. ... But strangely enough, some tests show that this is not the case. Even without the coercion, the type of `Button becomes fixed to 'a button. Looks like there is a bug in the interaction between classes and variants. So do not forget the coercion even if it works now without... Jacques Garrigue ------------------- 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