caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Pseudo-extensible records
@ 2003-10-15 11:33 Martin Jambon
  0 siblings, 0 replies; only message in thread
From: Martin Jambon @ 2003-10-15 11:33 UTC (permalink / raw)
  To: caml-list

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-10-15 11:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-15 11:33 [Caml-list] Pseudo-extensible records Martin Jambon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).