<?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="2002/07/159ef0ccc84f7c657489db370903e327"
  from="Oleg &lt;oleg_inconnu@m...&gt;"
  author="Oleg"
  date="2002-07-13T13:40:58"
  subject="[Caml-list] Five Questions about Objects"
  prev="2002/07/e279811039f13ecb6fc02cdc51f40b4f"
  next="2002/07/5a07099df93b470f2f48a69d7d4bf4a2"
  next-in-thread="2002/07/e609d5c80b3292d73cadaef94b22faa1"
  prev-thread="2002/07/e2f2b258abd0d3497431776b34442703"
  next-thread="2002/07/5a07099df93b470f2f48a69d7d4bf4a2"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] Five Questions about Objects">
<msg 
  url="2002/07/159ef0ccc84f7c657489db370903e327"
  from="Oleg &lt;oleg_inconnu@m...&gt;"
  author="Oleg"
  date="2002-07-13T13:40:58"
  subject="[Caml-list] Five Questions about Objects">
<msg 
  url="2002/07/e609d5c80b3292d73cadaef94b22faa1"
  from="YAMAGATA yoriyuki &lt;yoriyuki@m...&gt;"
  author="YAMAGATA yoriyuki"
  date="2002-07-14T02:01:08"
  subject="Re: [Caml-list] Five Questions about Objects">
<msg 
  url="2002/07/88ceff20a8333237e0473e41d8ebf755"
  from="Alain Frisch &lt;frisch@c...&gt;"
  author="Alain Frisch"
  date="2002-07-14T08:58:25"
  subject="Re: [Caml-list] Five Questions about Objects">
<msg 
  url="2002/07/2bd49e9e3d2bfef1b3b0efd6d37d8010"
  from="Jacques Garrigue &lt;garrigue@k...&gt;"
  author="Jacques Garrigue"
  date="2002-07-14T09:39:06"
  subject="Re: [Caml-list] Five Questions about Objects">
<msg 
  url="2002/07/7e73c73d2257ab2c68a534ee7340330c"
  from="William Lovas &lt;wlovas@s...&gt;"
  author="William Lovas"
  date="2002-07-14T10:24:02"
  subject="Re: [Caml-list] Five Questions about Objects">
</msg>
</msg>
</msg>
<msg 
  url="2002/07/8e7888e28c1b918c84298e36bdfb197e"
  from="Brian Smith &lt;blsmith@b...&gt;"
  author="Brian Smith"
  date="2002-07-20T12:56:50"
  subject="Re: [Caml-list] Five Questions about Objects">
<msg 
  url="2002/07/4a6d6ba66cbaf5fd1eb212e448adcbb0"
  from="YAMAGATA yoriyuki &lt;yoriyuki@m...&gt;"
  author="YAMAGATA yoriyuki"
  date="2002-07-20T15:49:38"
  subject="Re: [Caml-list] Five Questions about Objects">
</msg>
</msg>
</msg>
<msg 
  url="2002/07/75378d984912d08869be7863a3be88c1"
  from="Jacques Garrigue &lt;garrigue@k...&gt;"
  author="Jacques Garrigue"
  date="2002-07-14T03:32:58"
  subject="Re: [Caml-list] Five Questions about Objects">
</msg>
<msg 
  url="2002/07/f19d29f39c16d741976445296fba36ea"
  from="Xavier Leroy &lt;xavier.leroy@i...&gt;"
  author="Xavier Leroy"
  date="2002-07-14T20:08:40"
  subject="Re: [Caml-list] Five Questions about Objects">
<msg 
  url="2002/07/2737a7cea2fd0851c3767abc9726e20b"
  from="Oleg &lt;oleg_inconnu@m...&gt;"
  author="Oleg"
  date="2002-07-16T04:48:45"
  subject="Re: [Caml-list] Five Questions about Objects">
</msg>
<msg 
  url="2002/07/f178655b06c3af22c50aee33163cd56f"
  from="Oleg &lt;oleg_inconnu@m...&gt;"
  author="Oleg"
  date="2002-07-16T04:48:07"
  subject="Re: [Caml-list] Five Questions about Objects">
</msg>
</msg>
</msg>
</thread>

<contents>
Hi

A few questions on objects:

1) Why does the following code define a polymorphic class

 class point a b = 
    object 
      val x = a
      val y = b
    end;;

but adding "method get () = (x, y)" results in type errors only resolvable by 
specifying types with "class ['a, 'b] point (a:'a) (b:'b)" ? Why doesn't 

 class point a b = 
    object 
      val x = a
      val y = b
      method get () = (x, y)
    end;;

give me a polymorphic class?

2) What is the point of "class" and "new" keywords? How are they better than 
"let" ? E.g.

let point a b = 
  object
    val x = a
    val y = b
    method get () = (x, y)
  end;;

let my_point = point 3 7;; 
let many_float_points = Array.make 100 (point 4.0 3.0);;
?

3) Is it possible to access object datafields directly or only through 
methods?

4) Can I construct an object that the following function f would accept?
# let f a = a#m1 (); a#b#m2 ();;
val f : &lt; b : &lt; m2 : unit -&gt; 'a; .. &gt;; m1 : unit -&gt; 'b; .. &gt; -&gt; 'a = &lt;fun&gt;

I tried the obvious (to me) and it doesn't work. What is the precedence and 
associativity of #?

5) What is the current state of marshalling objects? Is Jacques's patch going 
to be used in the upcoming O'Caml version or is it too untested? 

Thanks
Oleg
-------------------
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

</contents>

</message>

