<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2006/02/d9cbd2362d0ee2336cbbdae6063a8272"
  from="Oliver Bandel &lt;oliver@f...&gt;"
  author="Oliver Bandel"
  date="2006-02-25T11:49:50"
  subject="Re: [Caml-list] multiple inheritance, bug or feature ?"
  prev="2006/02/af2129d76d17706f124c464488b55ccb"
  next="2006/02/14a34f8584252a88b013f61b18155090"
  prev-in-thread="2006/02/14a34f8584252a88b013f61b18155090"
  next-in-thread="2006/02/cee40211d278f8e8b32d72defe400753"
  prev-thread="2006/02/87492d48b7b7425a57ea516b1a7f2397"
  next-thread="2006/02/1681fddd9168a27c9d00d28b96b4af41"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="multiple inheritance, bug or feature ?">
<msg 
  url="2006/02/6c745cdabcb81f4abee3ab4848327146"
  from="sejourne_kevin &lt;sejourne_kevin@y...&gt;"
  author="sejourne_kevin"
  date="2006-02-25T10:50:24"
  subject="multiple inheritance, bug or feature ?">
<msg 
  url="2006/02/af2129d76d17706f124c464488b55ccb"
  from="Jacques Garrigue &lt;garrigue@m...&gt;"
  author="Jacques Garrigue"
  date="2006-02-25T11:44:36"
  subject="Re: [Caml-list] multiple inheritance, bug or feature ?">
<msg 
  url="2006/02/14a34f8584252a88b013f61b18155090"
  from="Oliver Bandel &lt;oliver@f...&gt;"
  author="Oliver Bandel"
  date="2006-02-25T11:56:18"
  subject="Re: [Caml-list] multiple inheritance, bug or feature ?">
</msg>
</msg>
<msg 
  url="2006/02/d9cbd2362d0ee2336cbbdae6063a8272"
  from="Oliver Bandel &lt;oliver@f...&gt;"
  author="Oliver Bandel"
  date="2006-02-25T11:49:50"
  subject="Re: [Caml-list] multiple inheritance, bug or feature ?">
<msg 
  url="2006/02/cee40211d278f8e8b32d72defe400753"
  from="sejourne_kevin &lt;sejourne_kevin@y...&gt;"
  author="sejourne_kevin"
  date="2006-02-25T11:59:01"
  subject="Re: [Caml-list] multiple inheritance, bug or feature ?">
<msg 
  url="2006/02/62c2392c4a811f218f097d57a0564198"
  from="Oliver Bandel &lt;oliver@f...&gt;"
  author="Oliver Bandel"
  date="2006-02-25T12:17:16"
  subject="Re: [Caml-list] multiple inheritance, bug or feature ?">
<msg 
  url="2006/02/1b75a8bb8bfe8ea1000b5732c70ea50a"
  from="Oliver Bandel &lt;oliver@f...&gt;"
  author="Oliver Bandel"
  date="2006-02-25T12:34:04"
  subject="Re: [Caml-list] multiple inheritance, bug or feature ?">
</msg>
</msg>
</msg>
</msg>
</msg>
</thread>

<contents>
On Sat, Feb 25, 2006 at 12:01:00PM +0100, sejourne_kevin wrote:
&gt; Hello :
&gt; 
&gt; 
&gt; Consider the following sample :
&gt; 
&gt; class a =
&gt; object
&gt;   val mutable x = 0
&gt;   method set v = Printf.printf "%d\n" x;x &lt;- v
&gt; end
&gt; ;;
[...]
 
&gt; class c :
&gt;   object
&gt;     val mutable x : int
&gt;     val mutable y : int
&gt;     method set : int -&gt; unit
&gt;     method set_x_a : int -&gt; unit
&gt;     method set_x_a' : int -&gt; unit
&gt;     method set_y : int -&gt; unit
&gt;   end
&gt; 
&gt; let d = new c;;
&gt; val d : c = &lt;obj&gt;
&gt; 
&gt; d#set_x_a 3;;
&gt; 0
&gt; - : unit = ()
&gt; 
&gt; d#set_x_a' 2;;
&gt; 0
&gt; - : unit = ()
&gt; 
&gt; 
&gt; When I wrote this program I expect this behavior but
&gt; 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 = &lt;obj&gt;
# 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 &lt;- v; Printf.printf "%d\n" x


Ciao,
   Oliver

</contents>

</message>

