caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* safe casting
@ 2007-08-22 18:33 Yitzhak Mandelbaum
  2007-08-22 22:20 ` [Caml-list] " David Allsopp
  0 siblings, 1 reply; 2+ messages in thread
From: Yitzhak Mandelbaum @ 2007-08-22 18:33 UTC (permalink / raw)
  To: caml-list

[-- 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 --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-08-22 22:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-22 18:33 safe casting Yitzhak Mandelbaum
2007-08-22 22:20 ` [Caml-list] " David Allsopp

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).