From: bluestorm <bluestorm.dylc@gmail.com>
To: Nicolas Ojeda Bar <nojb@math.harvard.edu>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] extending records with Obj.magic
Date: Mon, 30 Aug 2010 23:11:33 +0200 [thread overview]
Message-ID: <AANLkTinLFSsc=EVkUzRbZLMQ8cABQiYNKg-i3xVZZ8Sf@mail.gmail.com> (raw)
In-Reply-To: <231FBA54-C413-4696-AA70-216253EDF2DA@math.harvard.edu>
On Mon, Aug 30, 2010 at 11:04 PM, Nicolas Ojeda Bar
<nojb@math.harvard.edu> wrote:
> Hello,
>
> I need extensible records, and the code below seems to
> work. Are there any pitfall that I should be aware of?
> Could this mess up the GC?
>
> # type t0 = { a : int };
> # type t1 = { a2 : int; b : int };
> # value x1 = { a2 = 3; b = 5 };
> # value x0 : t0 = Obj.magic x1;
> value x0 = { a = 3 }
> # value x0' : t1 = Obj.magic x0;
> value x0' = { a2 = 3; b = 5 }
>
You could use objects instead.
ype t0 = < a : int >
type t1 = < a : int; b : int >
let x1 = object
method a = 3
method b = 5
end
let x0 = (x1 :> t0)
(downcasting x0 -> x0' isn't correct)
next prev parent reply other threads:[~2010-08-30 21:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20100830204956.2D927BC5D@yquem.inria.fr>
2010-08-30 21:04 ` Nicolas Ojeda Bar
2010-08-30 21:11 ` bluestorm [this message]
2010-08-30 21:43 ` [Caml-list] " Martin Jambon
2010-09-06 15:24 ` Goswin von Brederlow
2010-09-02 13:06 ` Bruno Barras
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='AANLkTinLFSsc=EVkUzRbZLMQ8cABQiYNKg-i3xVZZ8Sf@mail.gmail.com' \
--to=bluestorm.dylc@gmail.com \
--cc=caml-list@yquem.inria.fr \
--cc=nojb@math.harvard.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