From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 1DE5BBB81 for ; Sat, 25 Feb 2006 12:49:50 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k1PBnnEB030944 for ; Sat, 25 Feb 2006 12:49:49 +0100 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 MAA18842 for ; Sat, 25 Feb 2006 12:49:49 +0100 (MET) Received: from einhorn.in-berlin.de (einhorn.in-berlin.de [192.109.42.8]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k1PBnma8030941 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Sat, 25 Feb 2006 12:49:48 +0100 X-Envelope-From: oliver@first.in-berlin.de X-Envelope-To: Received: from first.in-berlin.de (e178033193.adsl.alicedsl.de [85.178.33.193]) (authenticated bits=0) by einhorn.in-berlin.de (8.12.10/8.12.10/Debian-4) with ESMTP id k1PBnh6r022051 for ; Sat, 25 Feb 2006 12:49:43 +0100 Received: by first.in-berlin.de (Postfix, from userid 501) id CDB4B2216E9; Sat, 25 Feb 2006 12:48:59 +0100 (CET) Date: Sat, 25 Feb 2006 12:48:59 +0100 From: Oliver Bandel To: caml-list@inria.fr Subject: Re: [Caml-list] multiple inheritance, bug or feature ? Message-ID: <20060225114859.GA460@first.in-berlin.de> References: <440038EC.5060302@yahoo.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <440038EC.5060302@yahoo.fr> User-Agent: Mutt/1.5.6i X-Scanned-By: MIMEDefang_at_IN-Berlin_e.V. on 192.109.42.8 X-Miltered: at nez-perce with ID 4400445D.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 4400445C.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; oliver:01 bandel:01 oliver:01 in-berlin:01 caml-list:01 bug:01 val:01 mutable:01 printf:01 printf:01 val:01 mutable:01 wrote:01 wrote:01 behaviour:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.3 On Sat, Feb 25, 2006 at 12:01:00PM +0100, sejourne_kevin wrote: > Hello : > > > Consider the following sample : > > class a = > object > val mutable x = 0 > method set v = Printf.printf "%d\n" x;x <- v > end > ;; [...] > class c : > object > val mutable x : int > val mutable y : int > method set : int -> unit > method set_x_a : int -> unit > method set_x_a' : int -> unit > method set_y : int -> unit > end > > let d = new c;; > val d : c = > > d#set_x_a 3;; > 0 > - : unit = () > > d#set_x_a' 2;; > 0 > - : unit = () > > > When I wrote this program I expect this behavior but > according to the warnings M the result should be 3. Why do you think the expected behaviour should be printing the 3? Your method prints the old value, not the new value. ======================= # let o = new c;; val o : c = # o#set_x_a 10;; 0 - : unit = () # o#set_x_a 20;; 10 - : unit = () # o#set_x_a 30;; 20 - : unit = () # ======================= If you want to print the current value after update, you should also write your code in the way it it does this. So, you should write it in this way: method set v = x <- v; Printf.printf "%d\n" x Ciao, Oliver