Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Pseudo-extensible records
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Martin Jambon <martin_jambon@e...>
Subject: [Caml-list] Pseudo-extensible records
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