From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 6BAEEBDDB for ; Sat, 3 Sep 2005 16:29:06 +0200 (CEST) Received: from mail.enyo.de (mail.enyo.de [212.9.189.167]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j83ET50N007595 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for ; Sat, 3 Sep 2005 16:29:06 +0200 Received: from deneb.vpn.enyo.de ([212.9.189.177] helo=deneb.enyo.de) by albireo.enyo.de with esmtp id 1EBZ0x-0001zO-OA; Sat, 03 Sep 2005 16:29:03 +0200 Received: from fw by deneb.enyo.de with local (Exim 4.52) id 1EBZ0M-0008SL-0d; Sat, 03 Sep 2005 16:28:26 +0200 From: Florian Weimer To: yoann padioleau Cc: Damien Bobillot , caml-list@yquem.inria.fr Subject: Re: [Caml-list] Unsafe features References: <87slwny8xs.fsf@mid.deneb.enyo.de> <2D13837B-0BDC-4E14-86DE-ADCCE2E3BC78@m4x.org> <87y86elcb2.fsf@mid.deneb.enyo.de> Date: Sat, 03 Sep 2005 16:28:26 +0200 In-Reply-To: (yoann padioleau's message of "Sat, 3 Sep 2005 14:07:22 +0200") Message-ID: <87slwmjkdx.fsf@mid.deneb.enyo.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Miltered: at concorde with ID 4319B331.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; florian:01 caml-list:01 val:01 heap:01 abstract:01 arbitrary:01 typing:01 define:01 unsafe:01 unsafe:01 int:01 int:01 output:02 types:02 seems:03 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 * yoann padioleau: >> Apparently, it creates a bit-wise copy of a value and assigns it a new >> type. > > Are you sure ? I thought it was just a function to get rid temporary > of the typing system, a kind of cast operator. It is, but how would you define such a operator? At a more abstract level, there is no obvious choice for a map a -> b between arbitrary types. I gave it a try and got: # let x : int = Obj.magic "x";; val x : int = 67381588 # x;; - : int = 67381588 # The "67381588" is just half the integral value of a heap address (because of the tag bit, I presume). And looking at the ltrace output, it seems that it is indeed close to the storage area of that string. > But is is bad to use it, very bad, shame on you if you use it > (i just put this statement to be sure that xavier leroy will not > shout over me). Yes, and my question was to avoid such unsafe language features.