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,NO_RELAYS autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: by yquem.inria.fr (Postfix, from userid 18041) id 4DA52BC6B; Wed, 27 Feb 2008 10:43:29 +0100 (CET) Date: Wed, 27 Feb 2008 10:43:29 +0100 To: David Teller Cc: Caml Subject: Re: [Caml-list] Safe Obj.magic container ? Message-ID: <20080227094329.GC13254@yquem.inria.fr> References: <1204103370.7718.18.camel@Blefuscu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1204103370.7718.18.camel@Blefuscu> User-Agent: Mutt/1.5.9i From: maranget@yquem.inria.fr (Luc Maranget) X-Spam: no; 0.00; maranget:01 maranget:01 semantics:01 semantics:01 ocaml:01 pointer:01 dynamically:01 luc:01 luc:01 caml-list:01 int:01 black:96 uniform:04 inria:06 discussion:06 > Along the lines of this discussion on Obj.magic, I have a question > about the semantics of the beast. I have not followed the discussion, but here are a few clues The semantics of Obj.magic is as follows: 1. Obj.magic does not exist. Don't use it. 2. Obj.magic is black magic, you can see it as the identity (fun x -> x) with type 'a -> 'b. As I see it, 2. steems from the uniform representation of values by OCaml. A value is either a scalar, or a pointer, and this can be tested dynamically (by looking at the low order bit) by Obj.is_int/Obj.is_block. -- Luc