From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id B051ABBCA for ; Wed, 27 Feb 2008 10:09:46 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAC+4xEfBMVMPn2dsb2JhbACQZwEBAQEBBgQGCQgYnEo X-IronPort-AV: E=Sophos;i="4.25,412,1199660400"; d="scan'208";a="9640930" Received: from kabis.univ-orleans.fr (HELO ka.univ-orleans.fr) ([193.49.83.15]) by mail3-smtp-sop.national.inria.fr with ESMTP; 27 Feb 2008 10:09:33 +0100 Received: from smtps.univ-orleans.fr (localhost [127.0.0.1]) by ka.univ-orleans.fr (Postfix) with ESMTP id 717A612AE90 for ; Wed, 27 Feb 2008 10:09:31 +0100 (CET) Received: from [192.168.0.1] (lau18-1-82-246-197-195.fbx.proxad.net [82.246.197.195]) by smtps.univ-orleans.fr (Postfix) with ESMTP id 4208236E5B for ; Wed, 27 Feb 2008 10:09:32 +0100 (CET) Subject: Safe Obj.magic container ? From: David Teller To: Caml Content-Type: text/plain Date: Wed, 27 Feb 2008 10:09:30 +0100 Message-Id: <1204103370.7718.18.camel@Blefuscu> Mime-Version: 1.0 X-Mailer: Evolution 2.12.1 Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; univ-orleans:01 semantics:01 variants:01 variants:01 univ-orleans:01 lifo:01 liquidations:98 polymorphic:01 polymorphic:01 inline:01 inline:01 variant:02 restrict:02 module:03 types:05 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.