<?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/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"
  prev="2002/07/9e01a26fdd4fa3e55e3d06ab91e39a95"
  next="2002/07/75378d984912d08869be7863a3be88c1"
  prev-in-thread="2002/07/159ef0ccc84f7c657489db370903e327"
  next-in-thread="2002/07/88ceff20a8333237e0473e41d8ebf755"
  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>
From: Oleg &lt;oleg_inconnu@myrealbox.com&gt;
Subject: [Caml-list] Five Questions about Objects
Date: Sat, 13 Jul 2002 09:42:47 -0400

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

I think You can't do like this.  object ... end is a part of a class
definition, and not an ordinary expression.

However, I wonder why a class is necessary in the first place.  I'm
not familiar with the theory of OOP, but I feel like direct creation
of objects is possible in functional languages.  It simplifies the
syntax, fits better the concept of functional programming, (I mean
the slogan that everything is an expression.) and more powerful.  Ok,
maybe it does not have much advantage over current approach, but if
both can do the same thing, why not use the simpler one?

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

# class ['b] b (v:'b) = object method m2 () = v end;;
class ['a] b : 'a -&gt; object method m2 : unit -&gt; 'a end
# class ['a, 'c] a (v1: 'c) (v2:'a b) = 
object method m1 () = v1 method b = v2 end;;
class ['a, 'b] a :
  'b -&gt; 'a b -&gt; object method b : 'a b method m1 : unit -&gt; 'b end
# f (new a 0 (new b 0));;
- : int = 0

--
Yamagata Yoriyuki
http://www.mars.sphere.ne.jp/yoriyuki/
-------------------
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>

