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=1.2 required=5.0 tests=AWL,HTML_MESSAGE,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id B2AD5BBCA for ; Wed, 27 Feb 2008 12:23:47 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAJfXxEfRVca4mGdsb2JhbACCOTWNeQEBAQEBBgQECQoYlCKIHQ X-IronPort-AV: E=Sophos;i="4.25,412,1199660400"; d="scan'208";a="23101018" Received: from rv-out-0910.google.com ([209.85.198.184]) by mail4-smtp-sop.national.inria.fr with ESMTP; 27 Feb 2008 12:23:47 +0100 Received: by rv-out-0910.google.com with SMTP id k20so1540370rvb.3 for ; Wed, 27 Feb 2008 03:23:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; bh=sL7/jwsrp4kSEaedy/6vYW/WddBElQ8wynZKhXWMeqc=; b=AneCk3yh6xCZw2E2v3DWuYS7ahFxJMx3pd6uJ0G38txVpEAUA72/JyfOUcWds2DkLaNwrdVAgH0XqU3ku0R4IS5BnP1n9k8ii6hWWu3pOBNuymalor74fJaY7GAUdYXdxAgRW3MetAgTsrFocnl/T9U5PHR5OrTQiAFNr7OpcdI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=To1pYb6zRKfqv5J+XMUE4EdqYmkt2GSJPvnuY5HliHeKM0rWkUMFyBWUrzQcO+1qYEg773cR1JmVdcPQ5st5c4EGmWoElfgkNfUSlvvIjzKcrIWAvHFPbqh7/55WFMHn7YDW8tGtsdBpbLJ+mjl7ABIzV0Yj1F7f8w/QEGuX5a0= Received: by 10.141.86.14 with SMTP id o14mr4370848rvl.148.1204111425845; Wed, 27 Feb 2008 03:23:45 -0800 (PST) Received: by 10.140.172.20 with HTTP; Wed, 27 Feb 2008 03:23:45 -0800 (PST) Message-ID: Date: Wed, 27 Feb 2008 12:23:45 +0100 From: "=?UTF-8?Q?Tom_Primo=C5=BEi=C4=8D?=" To: "David Teller" Subject: Re: [Caml-list] Safe Obj.magic container ? Cc: Caml In-Reply-To: <1204103370.7718.18.camel@Blefuscu> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_36489_7094770.1204111425839" References: <1204103370.7718.18.camel@Blefuscu> X-Spam: no; 0.00; presupposes:01 segfault:01 variants:01 pointer:01 presupposes:01 segfault:01 variants:01 pointer:01 polymorphic:01 polymorphic:01 caml-list:01 int:01 int:01 boolean:01 boolean:01 X-Attachments: cset="UTF-8" cset="UTF-8" ------=_Part_36489_7094770.1204111425839 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline The following are my experience and guesses, nothing scientific/official/thoroughly tested: > 1. can I assume that this is always going to work if u is 'a.'a ? Well, there is no type 'a.'a. You can have: type u = { everything: 'a . 'a } but this presupposes that values of type u are blocks (heap-allocated). Therefore, if you cast a boolean (true) to type u, and then try to access the everything field of the "new" value, you will get a segfault. 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 ? > type u = int this will work for any type. You can even do pointer manipulation with it (adding and subtracting even numbers of bytes). Sorry everybody. - Tom ------=_Part_36489_7094770.1204111425839 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline The following are my experience and guesses, nothing scientific/official/thoroughly tested:
1. can I assume that this is always going to work if u is 'a.'a   ?

Well, there is no type 'a.'a. You can have:
type u = { everything: 'a . 'a }
but this presupposes that values of type u are blocks (heap-allocated). Therefore, if you cast a boolean (true) to type u, and then try to access the everything field of the "new" value, you will get a segfault.

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 ?

type u = int
this will work for any type. You can even do pointer manipulation with it (adding and subtracting even numbers of bytes).

Sorry everybody.

 - Tom
------=_Part_36489_7094770.1204111425839--