From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p0QMWLlH022087 for ; Wed, 26 Jan 2011 23:32:21 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjMBAPouQE1CbwQZkWdsb2JhbACWWo4gFQEBAgkLCgcRBCC8dAWFT4UbhxI X-IronPort-AV: E=Sophos;i="4.60,382,1291590000"; d="scan'208";a="74273189" Received: from out1.smtp.messagingengine.com ([66.111.4.25]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/ADH-AES256-SHA; 26 Jan 2011 23:32:16 +0100 Received: from compute3.internal (compute3.nyi.mail.srv.osa [10.202.2.43]) by gateway1.messagingengine.com (Postfix) with ESMTP id 723232058B for ; Wed, 26 Jan 2011 17:32:15 -0500 (EST) Received: from frontend2.messagingengine.com ([10.202.2.161]) by compute3.internal (MEProxy); Wed, 26 Jan 2011 17:32:15 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=messagingengine.com; h=date:from:to:subject:message-id:references:mime-version:content-type:in-reply-to; s=smtpout; bh=1ag1Op69GZBzNWL4dzr3P3xQUsg=; b=nkzTb2Ng/JPLh5ee17M+s7Zpmt0dLlPKnPCOudaOgEmpxD0x+vYdAWEpGVuM/YAMK4CQDWQE1r4AK88XoQuvnjK6Tl2loahS/tTmI1yiYO8GmsTeO12n5xljqjHlfVMs6xKhYqFoYwA9S9Dm+WqVMoSTFJADn4OSQlYA/pwfqos= X-Sasl-enc: 36RDO/vqzBpDNrw2+C/HkTgvA2LxV5JcWMthFZzBzhpE 1296081135 Received: from localhost (PRYOR-VAIO.PHILOSOPHY.FAS.NYU.EDU [128.122.70.6]) by mail.messagingengine.com (Postfix) with ESMTPSA id 3DF6E441011 for ; Wed, 26 Jan 2011 17:32:15 -0500 (EST) Date: Wed, 26 Jan 2011 17:34:36 -0500 From: Jim Pryor To: caml-list@inria.fr Message-ID: <20110126223436.GB5907@vaio.jimpryor.net> Mail-Followup-To: caml-list@inria.fr References: <20110126221756.GA5907@vaio.jimpryor.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20110126221756.GA5907@vaio.jimpryor.net> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [Caml-list] Magic with fun (type t) ... ? On Wed, Jan 26, 2011 at 05:17:56PM -0500, Jim Pryor wrote: > I expect this is bad coding style, and should not be relied on. However, > I was surprised at the behavior, and wondered whether it was intended: > > # let f = fun (type t) x -> > let module M = struct exception E of t end in > M.E x;; > val f : 'a -> exn = > > f is polymorphic, as we expect: > > # f 1;; > - : exn = E 1 > # f "s";; > - : exn = E "s" > > But now notice: > > # f ();; > - : exn = E 0 > # f None;; > - : exn = E 0 > > It appears that non-heap values are always getting magicked into ints. > > Has this been noted before? I expect it's probably harmless, because what could you do with the exception value in question? Since it's leaked outside the scope of its type declaration, I can't see any (unmagicky) way to deconstruct it. But as I said, this behavior struck me as odd. I would more have expected an error. -- Jim Pryor profjim@jimpryor.net