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=4.1 required=5.0 tests=AWL,DNS_FROM_RFC_POST, DNS_FROM_SECURITYSAGE,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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id BC751BB84 for ; Fri, 14 Nov 2008 17:24:07 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgMDALQ0HUnAXQIngWdsb2JhbACTGz4BARYisUWLLgEDAQOCdYIK X-IronPort-AV: E=Sophos;i="4.33,603,1220220000"; d="scan'208";a="19195401" Received: from concorde.inria.fr ([192.93.2.39]) by mail3-smtp-sop.national.inria.fr with ESMTP; 14 Nov 2008 17:24:07 +0100 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id mAEGO6e2005532 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Fri, 14 Nov 2008 17:24:07 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvcAAHk0HUlA6ba+imdsb2JhbACTGz4BAQEKCQwHDwWxQosuAQMBA4J1ggo X-IronPort-AV: E=Sophos;i="4.33,603,1220220000"; d="scan'208";a="31464645" Received: from nf-out-0910.google.com ([64.233.182.190]) by mail4-smtp-sop.national.inria.fr with ESMTP; 14 Nov 2008 17:24:06 +0100 Received: by nf-out-0910.google.com with SMTP id d3so864903nfc.7 for ; Fri, 14 Nov 2008 08:24:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:cc:message-id:from:to :in-reply-to:content-type:content-transfer-encoding:mime-version :subject:date:references:x-mailer:sender; bh=T6a5/K+zezxm+U+kB1suPR+5loTY1cZXur3jry0j7tE=; b=tUISaLdXgB5rmq9cR5qNOKnExpMtLAH/9TfuMAwn1MAC7ddOp2j9hErPHfFraEPRU2 zBGL4MkwGu9WLavb0FOJ1tHNzsOdg0vuwxFJp9d5v6gErsxkb9jZMr5EXSQ8ycsrsXds LzTiNTIbOcnHFWYZ6n+QHZoTox4I/HHkRls/E= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=cc:message-id:from:to:in-reply-to:content-type :content-transfer-encoding:mime-version:subject:date:references :x-mailer:sender; b=MXaVzbiYoxSNzD4b6btRRT0IWG0/qlRuHNZ1AL4+47y9o4NBvCzQOWSRwXILdrC1g9 lquU9A8972tQmLIJ/wn9940n/9U9c5sqOp38MNbAqbLxOoWDVnqCJKPn9YNv/CbIr0CQ w6Uw17h2+u7Aq7kSZ5D9n3RvHq99TVakCtx2I= Received: by 10.103.24.11 with SMTP id b11mr383884muj.58.1226679845844; Fri, 14 Nov 2008 08:24:05 -0800 (PST) Received: from ?192.168.1.34? (50-22.76-83.cust.bluewin.ch [83.76.22.50]) by mx.google.com with ESMTPS id u26sm1031663mug.5.2008.11.14.08.24.05 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 14 Nov 2008 08:24:05 -0800 (PST) Cc: Romain Beauxis Message-Id: <7575FB76-0B64-4AE3-8A13-00F6514AFBA9@erratique.ch> From: =?ISO-8859-1?Q?Daniel_B=FCnzli?= To: OCaml Mailing List In-Reply-To: <200811141658.31079.toots@rastageeks.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed; delsp=yes Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Apple Message framework v929.2) Subject: Re: [Caml-list] Big array with data managed by another value Date: Fri, 14 Nov 2008 17:23:04 +0100 References: <200811141503.43395.toots@rastageeks.org> <4A8FA99F-D6C3-4D99-AC8D-E17CEE94C88F@erratique.ch> <15DBBCF2-79EF-4F08-A589-3E1B9B4EECB5@erratique.ch> <200811141658.31079.toots@rastageeks.org> X-Mailer: Apple Mail (2.929.2) Sender: =?UTF-8?B?RGFuaWVsIELDvG56bGk=?= X-Miltered: at concorde with ID 491DA626.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; bunzli:01 buenzli:01 bigarray:01 bigarray:01 val:01 -unsafe:01 caml-list:01 data:02 callback:02 bounds:02 let:03 let:03 raise:03 scope:04 daniel:04 Le 14 nov. 08 =E0 16:58, Romain Beauxis a =E9crit : > Yep, that's my current solution. Another less friendly solution is to provide the bigarray in a =20 callback and document the fact that the bigarray is only valid for the =20= call and should not escape the scope. val with_bigarray : custom -> (bigarray -> 'a) -> 'a let with_bigarray c f =3D let ba =3D barray_of c in try let r =3D f ba in barray_invalidate ba; r with e -> =20 barray_invalidate ba; raise e barray_invalidate should set the bigarray size to 0 so that if the =20 client doesn't respect the policy it will only get an out of bounds =20 error (unless he compiled with -unsafe). Best, Daniel