<?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/3514d436ed9f160807888aa6f0870822"
  from="Martin Jambon &lt;martin_jambon@e...&gt;"
  author="Martin Jambon"
  date="2003-10-15T11:34:10"
  subject="[Caml-list] Pseudo-extensible records"
  prev="2003/10/57c7a1c5ff0f45f78d981bdff9210697"
  next="2003/10/a1da1088efdb9e488b62d38e41e18696"
  prev-thread="2003/10/c1af550ea8aa0a1e792263146a015857"
  next-thread="2003/10/702773fd728055d4a47e1db53ea3cc20"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] Pseudo-extensible records">
<msg 
  url="2003/10/3514d436ed9f160807888aa6f0870822"
  from="Martin Jambon &lt;martin_jambon@e...&gt;"
  author="Martin Jambon"
  date="2003-10-15T11:34:10"
  subject="[Caml-list] Pseudo-extensible records">
</msg>
</thread>

<contents>
Hello,

I was thinking of some way to define record types with
"the same fields plus some others":

(** point2.mli **)
type point2 = { x : float;
                y : float }

(** point3.ml **)
type point3 = { include Point2.point2;
                z : float }

(* which would be exactly equivalent as writing *)
type point3 = { x : float;
                y : float;
                z : float }

Some disavantadges:
- same field labels but no subtyping
  (and all the usual problems that we don't have with classes and objects)

Some advantages:
- can be used where objects cannot (input/output_value are possible)
- makes some type definitions more clear


My initial problem is to input/output objects with a minimum of efforts.
If we have one module for each class, with some hand-written conversion
from/to record types, maybe it would be convenient to have a
such a pseudo-inheritance system for record types.

Any experience with this kind of problem?

Unless Marshal becomes available for objects?...


-- Martin

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

