From: "Nicolas Pouillard" <nicolas.pouillard@gmail.com>
To: "Raj B" <rajb@rice.edu>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] OCaml object types vs record types
Date: Mon, 4 Jun 2007 22:13:59 +0200 [thread overview]
Message-ID: <cd67f63a0706041313sc3680a9j258c92213460e1b8@mail.gmail.com> (raw)
In-Reply-To: <0EE1C559-A93C-4E66-AC70-8ADD1C21DDF8@rice.edu>
On 6/4/07, Raj B <rajb@rice.edu> wrote:
> Hi there
>
> I'm writing an application where I'd modeling objects as record
> types. However, I'd like to have a subtyping relation between them
> along with (occasional) coercion. For example,
>
> type obj = {name : string}
> type specialobj = {name: string; mutable value: int;...}
> and so on...
>
The pa_oo extension from Jacques Garrigue does exactly this kind of things:
http://www.math.nagoya-u.ac.jp/~garrigue/code/ocaml.html
(works also in 3.10 but not released yet, contact me if you want it)
Example:
type obj = <name : string>
type specialobj = <name: string; value: int; set_value: int -> unit...>
let o = {| name = "foo"; mutable value = 42 |}
in o#name, o#value <- 43, o#value
Regards,
--
Nicolas Pouillard
next prev parent reply other threads:[~2007-06-04 20:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-04 16:45 Raj B
2007-06-04 19:55 ` [Caml-list] " Pierre-Evariste Dagand
2007-06-04 20:13 ` Nicolas Pouillard [this message]
2007-06-04 22:06 ` Lukasz Stafiniak
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=cd67f63a0706041313sc3680a9j258c92213460e1b8@mail.gmail.com \
--to=nicolas.pouillard@gmail.com \
--cc=caml-list@yquem.inria.fr \
--cc=rajb@rice.edu \
/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