Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Martin Jambon <martin_jambon@emailuser.net>
To: caml-list@inria.fr
Subject: [Caml-list] Pseudo-extensible records
Date: Wed, 15 Oct 2003 13:33:51 +0200 (CEST)	[thread overview]
Message-ID: <Pine.LNX.4.40.0310151252380.1970-100000@mj.medit.fr> (raw)

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


                 reply	other threads:[~2003-10-15 11:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.40.0310151252380.1970-100000@mj.medit.fr \
    --to=martin_jambon@emailuser.net \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox