From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE autolearn=disabled version=3.1.3 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 243C9BC0A for ; Mon, 21 May 2007 08:04:29 +0200 (CEST) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l4L64QV8024714 for ; Mon, 21 May 2007 08:04:28 +0200 Received: from localhost (orion [130.54.16.5]) by kurims.kurims.kyoto-u.ac.jp (8.13.7/8.13.7) with ESMTP id l4L64J45012836; Mon, 21 May 2007 15:04:20 +0900 (JST) Date: Mon, 21 May 2007 15:04:10 +0900 (JST) Message-Id: <20070521.150410.48799413.garrigue@math.nagoya-u.ac.jp> To: micha-1@fantasymail.de Cc: caml-list@inria.fr Subject: Re: [Caml-list] virtual instance variables From: Jacques Garrigue In-Reply-To: <20070518205020.59b45b61@hmmm.de> References: <20070518205020.59b45b61@hmmm.de> X-Mailer: Mew version 4.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 4651366B.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; toplevel:01 val:01 val:01 bug:01 ocaml:01 reverted:01 ocaml:01 cvs:01 exception:01 behaviour:01 behaviour:01 caml-list:01 inherit:01 inherit:01 coercion:01 From: micha > entering in the toplevel: > > class virtual c = object val virtual d : int end;; > > then: > > class d = object inherit c val d = 9 end;; > > gives me: Exception: Not_found. > What is not found? (compiling works) Great, you found the first bug in this release! To trigger it you must create a virtual instance variable without using it (which is certainly useless, but allowed.) This is now fixed in CVS. Note that if you write class virtual c = object val virtual d : int method d = d end;; there is of course no problem. > if I define: > class virtual c = object val d = 0 end;; > class d = object inherit c val d = 9 end;; > > gives the warning: > Warning V: the instance variable d is overriden. > The behaviour changed in ocaml 3.10 (previous behaviour was hiding.) > > I thought that without the virtual declaration the behaviour is the > same as before? No, it is not. Or, more precisely, we reverted to the behviour of ocaml 1. Visible instance variables are merged. To avoid this, you must hide the first d by a coercion: class d = object inherit (c : object end) val d = 9 end;; Jacques Garrigue