<?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/fe6b3048ed9db4da74f54d088173989d"
  from="David Brown &lt;caml-list@d...&gt;"
  author="David Brown"
  date="2003-10-21T19:08:05"
  subject="Re: [Caml-list] OCaml wishlist"
  prev="2003/10/5dd71e02247c880498f410c239374234"
  next="2003/10/2452fac51ab932ac2bd176e8183a524f"
  prev-in-thread="2003/10/e051e894779e1d750dc514438ac003da"
  next-in-thread="2003/10/23b761709f504ab6af2a1f09d8d07c5a"
  prev-thread="2003/10/486acf652571889eddb2bd9834f62d74"
  next-thread="2003/10/36ad1eb7cafe994a34e3761a559f87ee"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] OCaml wishlist">
<msg 
  url="2003/10/08bd0ecfdca5cc2e49c8e01b5c9d4507"
  from="Richard Jones &lt;rich@a...&gt;"
  author="Richard Jones"
  date="2003-10-21T14:29:23"
  subject="[Caml-list] OCaml wishlist">
<msg 
  url="2003/10/cb6d61f43e94f4bec873d3522da4dfad"
  from="Michal Moskal &lt;malekith@p...&gt;"
  author="Michal Moskal"
  date="2003-10-21T15:00:19"
  subject="Re: [Caml-list] OCaml wishlist">
<msg 
  url="2003/10/5dd71e02247c880498f410c239374234"
  from="Richard Jones &lt;rich@a...&gt;"
  author="Richard Jones"
  date="2003-10-21T17:17:16"
  subject="Re: [Caml-list] OCaml wishlist">
</msg>
<msg 
  url="2003/10/2452fac51ab932ac2bd176e8183a524f"
  from="William Lovas &lt;wlovas@s...&gt;"
  author="William Lovas"
  date="2003-10-21T19:01:56"
  subject="Re: [Caml-list] OCaml wishlist">
<msg 
  url="2003/10/a1b78b7694f2d67a6e6b7db51de25f98"
  from="Alain.Frisch@e..."
  author="Alain.Frisch@e..."
  date="2003-10-21T19:46:45"
  subject="Re: [Caml-list] OCaml wishlist">
</msg>
<msg 
  url="2003/10/7497ee1b70d6745da11d738b9572fbe3"
  from="Richard Jones &lt;rich@a...&gt;"
  author="Richard Jones"
  date="2003-10-21T19:54:09"
  subject="Re: [Caml-list] OCaml wishlist">
<msg 
  url="2003/10/5ad948ee2283f3ece3b1bc3cf4238ccb"
  from="Yaron Minsky &lt;yminsky@c...&gt;"
  author="Yaron Minsky"
  date="2003-10-21T20:27:09"
  subject="Re: [Caml-list] OCaml wishlist">
</msg>
<msg 
  url="2003/10/528446ab0441688dd60d9d0c2ad9a9d3"
  from="Yaron Minsky &lt;yminsky@c...&gt;"
  author="Yaron Minsky"
  date="2003-10-21T20:53:04"
  subject="Re: [Caml-list] OCaml wishlist">
<msg 
  url="2003/10/f4aa63fac624d2412ec939b942d8eb7d"
  from="Alain.Frisch@e..."
  author="Alain.Frisch@e..."
  date="2003-10-21T21:46:42"
  subject="Re: [Caml-list] OCaml wishlist">
</msg>
</msg>
<msg 
  url="2003/10/a24e55f813003425848ab701e4e4741d"
  from="Jacques Garrigue &lt;garrigue@k...&gt;"
  author="Jacques Garrigue"
  date="2003-10-22T00:59:50"
  subject="Re: [Caml-list] OCaml wishlist">
<msg 
  url="2003/10/0387387ca1566a60c7eb714103fcafca"
  from="Brian Hurt &lt;bhurt@s...&gt;"
  author="Brian Hurt"
  date="2003-10-22T02:52:43"
  subject="Re: [Caml-list] OCaml wishlist">
<msg 
  url="2003/10/e051e894779e1d750dc514438ac003da"
  from="Michal Moskal &lt;malekith@p...&gt;"
  author="Michal Moskal"
  date="2003-10-22T15:30:15"
  subject="Re: [Caml-list] OCaml wishlist">
</msg>
</msg>
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2003/10/fe6b3048ed9db4da74f54d088173989d"
  from="David Brown &lt;caml-list@d...&gt;"
  author="David Brown"
  date="2003-10-21T19:08:05"
  subject="Re: [Caml-list] OCaml wishlist">
</msg>
<msg 
  url="2003/10/23b761709f504ab6af2a1f09d8d07c5a"
  from="Alain.Frisch@e..."
  author="Alain.Frisch@e..."
  date="2003-10-21T19:18:33"
  subject="Re: [Caml-list] OCaml wishlist">
</msg>
</msg>
</thread>

<contents>
On Tue, Oct 21, 2003 at 03:29:21PM +0100, Richard Jones wrote:

&gt; 1. 'return' from a function. eg:
&gt; 
&gt;   let foo x =
&gt;     if x &lt; 0 then return "OSL";
&gt;     (* long &amp; complex code *)
&gt;     return "some other string"

let return x = x

&gt; 2. abstract data type syntactic sugar:
&gt; 
&gt;    let hash = Hashtbl.create 16 in
&gt;    hash#add "foo" 10;		or:   hash-&gt;add "foo" 10;
&gt;    hash#add "bar" 20;		or:   hash-&gt;add "bar" 20;
&gt; 
&gt;    The syntactic sugar is that if a module contains a type called
&gt;    M.t (literally "type t"), and obj has type M.t, then:
&gt; 
&gt;    obj#call		      [	or:   obj-&gt;call ]
&gt; 
&gt;    is exactly equivalent to:
&gt; 
&gt;    M.call obj

As pointed out in another post, there are type issues with this.  These
new constructs have to be polymorphic in the same ways that objects are.
If you want an object interface to something, it is probably best to
just do it that way.

&gt;    I think this change would help a lot of Java programmers (&lt;gr&gt;) who
&gt;    would otherwise tend to jump immediately on using objects, which are
&gt;    an area where OCaml is weaker.

I'm curious what the argument for Ocaml objects being weaker is.  For
the most part, the OCaml object system is much more flexible, mostly
because class inheritance and type inheritance are kept seperate.  Are
you complaining that coersion has to be explicit, and that you can't
cast to a more specific type?

I would suspect most instances of needing these casts in Java is due to
Java's much weaker type system.

There are some problems where an OO solution maps well to the problem.
There are many other problems where trying to force it into an OO model
only obscures the problem.  Ocaml is nice in that it gives you a choice.
The flexibility occasionally means that a particular model may not be as
easy to use as in a language where that is the only model available.

Dave

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

