caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Yitzhak Mandelbaum <yitzhak@research.att.com>
To: caml-list@yquem.inria.fr
Subject: safe casting
Date: Wed, 22 Aug 2007 14:33:39 -0400	[thread overview]
Message-ID: <72195753-8535-4D6F-BD60-79ED3C21B5D9@research.att.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 728 bytes --]

Hi,

Given two record types that are identical but in name, is it safe (if  
perhaps a poor idea) to cast between functions that are parametric in  
these record types:

e.g. Given,

module A =
struct
   type t = {a:int}
end

module B =
struct
   type t = {a:int}
end

Is this safe ?

module F(Ty: sig type t = {a:int} end) =
struct
   let extract {Ty.a=x} = x
end

module F_A = F(A)
let y = {B.a=3}
(Obj.magic F_A.extract) y

Put another way:  is the implementation of two records w/ identical  
labels the same, or is there a runtime significance to their static  
difference?

Thanks,
Yitzhak

--------------------------------------------------
Yitzhak Mandelbaum
AT&T Labs - Research

http://www.research.att.com/~yitzhak



[-- Attachment #2: Type: text/html, Size: 5859 bytes --]

             reply	other threads:[~2007-08-22 18:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-22 18:33 Yitzhak Mandelbaum [this message]
2007-08-22 22:20 ` [Caml-list] " David Allsopp

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=72195753-8535-4D6F-BD60-79ED3C21B5D9@research.att.com \
    --to=yitzhak@research.att.com \
    --cc=caml-list@yquem.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;
as well as URLs for NNTP newsgroup(s).