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 discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 67342BC0A for ; Thu, 5 Apr 2007 11:57:45 +0200 (CEST) Received: from [128.93.11.101] (buzet.inria.fr [128.93.11.101]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l359viLu006493 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 5 Apr 2007 11:57:44 +0200 Message-ID: <4614C73A.6070306@inria.fr> Date: Thu, 05 Apr 2007 11:54:02 +0200 From: Alain Frisch User-Agent: Thunderbird 1.5.0.7 (X11/20060927) MIME-Version: 1.0 To: Roland Zumkeller Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Polymorphic recursion References: <6f9f8f4a0704030959l8ebb155g8532e3ee6d31c66d@mail.gmail.com> <4613C0AA.8010405@inria.fr> <4613C22E.5060206@inria.fr> <4614037E.6060709@inria.fr> In-Reply-To: X-Enigmail-Version: 0.94.0.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Miltered: at discorde with ID 4614C818.001 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; frisch:01 frisch:01 recursion:01 well-typed:01 coq:01 ocaml:01 type-checker:01 translating:01 coq:01 lambda:01 ocamlopt:01 ocamlc:01 bug:01 polymorphic:01 wrote:01 Roland Zumkeller wrote: > On 04/04/07, Alain Frisch wrote: >> The fact that something is well-typed in Coq does not mean that you can >> just translate it to OCaml by adding a few Obj.magic to make the >> type-checker happy. > > As I understand Pierre Letouzey's PhD thesis explains how this can be > done. Your example couldn't result from translating a Coq term, since > "String.copy", "ref", and "Gc.major" are not part of its formalism (a > flavour of lambda calculus with inductive types). Here is an example which might fall into this class: let f n = let x = if ("a" = "b") then Obj.magic 0 else (Some n) in for i = 0 to 100000 do ignore (Some i) done; (match x with Some n -> print_int n | None -> ()); in f 10 It prints 512 on my machine (when compiled with ocamlopt). > On my machine it prints "$d$d$d$d$d$d$d$d$d$d$d$d$d$d$d" and when > compiled with ocamlc "abc". Is this a bug? No, undefined behaviors are not specified. -- Alain