caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Safe Obj.magic container ?
@ 2008-02-27  9:09 David Teller
  2008-02-27  9:43 ` [Caml-list] " Luc Maranget
  2008-02-27 11:23 ` Tom Primožič
  0 siblings, 2 replies; 11+ messages in thread
From: David Teller @ 2008-02-27  9:09 UTC (permalink / raw)
  To: Caml

   Along the lines of this discussion on Obj.magic, I have a question
about the semantics of the beast. 

 Assuming that I have two types t and u and a value v of type t, under
which conditions on t and u is it safe to Obj.magic v to type u, pass u
around a few times and Obj.magic it back to type t ? 


In particular
1. can I assume that this is always going to work if u is 'a.'a   ?

2. if t is a polymorphic variant written inline without a type name, can
I assume that if I write the same inline definition in another module,
it will have the same internal representation ?

3. assuming the answer to 1. is No, is there a type u or a simple
manipulation which should work for any type t ? Or perhaps just for
polymorphic variants ?

My guesses are 
1. No
2. Yes
3. Possibly if I restrict myself to polymorphic variants. Otherwise,
perhaps by playing with Deriving's Typeable.

Thanks,
 David
-- 
David Teller
 Security of Distributed Systems
  http://www.univ-orleans.fr/lifo/Members/David.Teller
 Angry researcher: French Universities need reforms, but the LRU act brings liquidations. 


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

end of thread, other threads:[~2008-02-29  8:18 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-27  9:09 Safe Obj.magic container ? David Teller
2008-02-27  9:43 ` [Caml-list] " Luc Maranget
     [not found]   ` <37B36607-9F22-4537-B4DB-1E04348E2B90@inria.fr>
2008-02-28 14:23     ` Damien Doligez
2008-02-28 15:29       ` David Teller
2008-02-28 16:24         ` Damien Doligez
2008-02-29  1:52         ` Jacques Garrigue
2008-02-29  8:18           ` David Teller
2008-02-28 19:20       ` Jake Donham
2008-02-28 23:19         ` Richard Jones
2008-02-27 11:23 ` Tom Primožič
2008-02-27 21:22   ` David Teller

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