<?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="2003/10/2c38ef89fcee5bfcb051460d8e0d485f"
  from="Jacques Garrigue &lt;garrigue@k...&gt;"
  author="Jacques Garrigue"
  date="2003-10-22T01:14:47"
  subject="Re: [Caml-list] OCaml wishlist"
  prev="2003/10/a24e55f813003425848ab701e4e4741d"
  next="2003/10/0387387ca1566a60c7eb714103fcafca"
  prev-in-thread="2003/10/36ad1eb7cafe994a34e3761a559f87ee"
  next-in-thread="2003/10/37ee21d15661a558c82cc9e8b9ac551d"
  prev-thread="2003/10/08bd0ecfdca5cc2e49c8e01b5c9d4507"
  next-thread="2003/10/865d716a1499fe5a9cc13f60e84a8a3e"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="Re: [Caml-list] OCaml wishlist">
<msg 
  url="2003/10/36ad1eb7cafe994a34e3761a559f87ee"
  from="Richard Jones &lt;rich@a...&gt;"
  author="Richard Jones"
  date="2003-10-21T22:39:22"
  subject="Re: [Caml-list] OCaml wishlist">
<msg 
  url="2003/10/2c38ef89fcee5bfcb051460d8e0d485f"
  from="Jacques Garrigue &lt;garrigue@k...&gt;"
  author="Jacques Garrigue"
  date="2003-10-22T01:14:47"
  subject="Re: [Caml-list] OCaml wishlist">
<msg 
  url="2003/10/37ee21d15661a558c82cc9e8b9ac551d"
  from="samsaga2 &lt;samsaga2@s...&gt;"
  author="samsaga2"
  date="2003-10-22T10:52:02"
  subject="Re: [Caml-list] OCaml wishlist -&gt; my wish">
</msg>
<msg 
  url="2003/10/b10283d8300b4f100899009b6735c9f9"
  from="brogoff@s..."
  author="brogoff@s..."
  date="2003-10-22T13:21:30"
  subject="Re: [Caml-list] OCaml wishlist">
</msg>
<msg 
  url="2003/10/34f3190c6d99486609f1bcf1a25eb523"
  from="Eray Ozkural &lt;exa@k...&gt;"
  author="Eray Ozkural"
  date="2003-10-23T00:32:15"
  subject="Re: [Caml-list] OCaml wishlist">
</msg>
<msg 
  url="2003/10/524383af3fd063e600f8875e23deb14b"
  from="skaller &lt;skaller@o...&gt;"
  author="skaller"
  date="2003-10-23T16:55:55"
  subject="Re: [Caml-list] OCaml wishlist">
</msg>
</msg>
</msg>
</thread>

<contents>
From: Richard Jones &lt;rich@annexia.org&gt;

&gt; Thanks for your answer David. In response to the above, I'd say that
&gt; I've found OCaml objects to generally be OK, but sometimes they can be
&gt; really infuriating! Examples:
&gt; 
&gt; * Type inference doesn't work sometimes, so you need to add 'just the
&gt;   right' type declaration to an expression to get it to compile.

Yes, that's most unfortunate.
There are two such difficulties with classes
* use of polymorphic or labelled methods (you need to know the type of
  the objects)
* escaping type variables in class definitions
For the first one, there is little to be done: whenever you call such
a method, you must make sure the type of the object is known.
For the second one, there is maybe some room for improvement.

&gt; * Upcasting - sometimes it works, sometimes it requires an explicit
&gt;   :&gt; to upcast. Once or twice I've had a really strange error where
&gt;   I've needed to do some sort of double upcast-and-type-declaration,
&gt;   IIRC it was (obj :&gt; superclass : superclass)

It should be  (obj : current :&gt; superclass).
This is the only "guaranteed" cast.
Otherwise, you are trying your luck. Still, simple cast should work
for all non-recursive classes.

&gt; * Polymorphic methods have a really odd &amp; unintuitive syntax.

Sorry. My idea was that they would only be used in very special cases,
particularly considering the typing problem described above.

&gt; * It seems like you need to use a separate MLI file to be able to
&gt;   define completely private (as opposed to just protected) methods,
&gt;   which isn't really documented well.

Not quite: you can also define a class type by hand and constrain your
definition with it.

class c : ct = object ... end

This may be surprising when coming from Java, but this is more
coherent with the rest of the language.

Overall, I would not characterize ocaml objects as weak, but rather
nonintuitive.

Jacques Garrigue

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

