<?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/07/0c7727744a42d1a2c9eeb08c4df40728"
  from="Fernando Alegre &lt;fernando@c...&gt;"
  author="Fernando Alegre"
  date="2003-07-05T07:46:55"
  subject="Re: [Caml-list] subtyping, polymorphism, higher order types....."
  prev="2003/07/6fb9d2897cba518cab99e18cea396c7a"
  next="2003/07/47c86cd9157db833717298b5eff903e4"
  prev-in-thread="2003/07/6fb9d2897cba518cab99e18cea396c7a"
  next-in-thread="2003/07/da08ccf0eadd794f5980a4f8a044d49e"
  prev-thread="2003/07/9d5c44985ef4846fa1879e4f91dc551f"
  next-thread="2003/07/c8147b1a3fde487932256f4013f9c14f"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] subtyping, polymorphism, higher order types.....">
<msg 
  url="2003/07/49ed1832a167d71344f550f25717a45f"
  from="Shaddin Doghmi &lt;shaddin@m...&gt;"
  author="Shaddin Doghmi"
  date="2003-07-03T14:33:27"
  subject="[Caml-list] subtyping, polymorphism, higher order types.....">
<msg 
  url="2003/07/0235d8bf220e9fe63e99b346ae379d7b"
  from="brogoff@s..."
  author="brogoff@s..."
  date="2003-07-03T16:55:32"
  subject="Re: [Caml-list] subtyping, polymorphism, higher order types.....">
</msg>
<msg 
  url="2003/07/c6d81119241d5306bafb0f9bc21d61e9"
  from="Daniel Weil &lt;daniel.weil@a...&gt;"
  author="Daniel Weil"
  date="2003-07-04T06:43:23"
  subject="Re: [Caml-list] subtyping, polymorphism, higher order types.....">
</msg>
<msg 
  url="2003/07/9265629f02a5161f666b1798bc5cc5e1"
  from="Vasile Rotaru &lt;vrotaru@s...&gt;"
  author="Vasile Rotaru"
  date="2003-07-04T21:31:54"
  subject="Re: [Caml-list] subtyping, polymorphism, higher order types.....">
<msg 
  url="2003/07/6fb9d2897cba518cab99e18cea396c7a"
  from="Jacques Garrigue &lt;garrigue@k...&gt;"
  author="Jacques Garrigue"
  date="2003-07-05T02:21:17"
  subject="Re: [Caml-list] subtyping, polymorphism, higher order types.....">
<msg 
  url="2003/07/0c7727744a42d1a2c9eeb08c4df40728"
  from="Fernando Alegre &lt;fernando@c...&gt;"
  author="Fernando Alegre"
  date="2003-07-05T07:46:55"
  subject="Re: [Caml-list] subtyping, polymorphism, higher order types.....">
</msg>
<msg 
  url="2003/07/da08ccf0eadd794f5980a4f8a044d49e"
  from="Vasile Rotaru &lt;vrotaru@s...&gt;"
  author="Vasile Rotaru"
  date="2003-07-05T15:53:36"
  subject="Re: [Caml-list] subtyping, polymorphism, higher order types.....">
</msg>
</msg>
</msg>
</msg>
</thread>

<contents>
On Sat, Jul 05, 2003 at 11:21:26AM +0900, Jacques Garrigue wrote:

&gt; This looks very much like an ocaml object type to me...
&gt; Is the absence of labels for fields important?
&gt; 
&gt; Note that you can also encode the above with polymorphism:
&gt; 
&gt;   type 'a point = int * int * 'a
&gt;   type 'a color_point = (int * 'a) point
&gt; 
&gt; The only trouble here is that there is no way to create heterogeneous
&gt; collections, since you cannot coerce a [unit color_point] to a [unit
&gt; point]. Actually, this just comes from a missing relation in the ocaml
&gt; type algebra: the type Obj.t is not recognized as a supertype for all
&gt; types. If this were the case then you would be able to write:
&gt;   let l = [ (p :&gt; Obj.t point); (cp :&gt; Obj.t point) ]
&gt; 
&gt; That would be easy enough to add, but is it that useful?

I think yes. That would allow us to avoid creating ad-hoc classes whose only
use is such heterogeneous storage. This would save quite a few lines of
wrapping code when the basic data structure is a record or a sum type that
is extended with a problem-specific type.

Currently, the problem is not just heterogeneous collections. In our program,
a mutable variable of type 'a model can not be reused to solve one model
after another without exiting the program and restarting with a different
model, unless we wrap everything in classes. Exiting the program is really
inconvenient for interactive user interfaces, and wrapping the code adds
many unnecessary lines. So, something like Obj.t coercion would be really
useful. 

Fernando

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

