From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id A82FCBC57 for ; Sat, 10 Jul 2010 14:41:40 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ao4BADsHOExCbwQbkWdsb2JhbACUC4xAFQEBAQEJCwoHEQQevH8FhSeEIoQugjo X-IronPort-AV: E=Sophos;i="4.55,179,1278280800"; d="scan'208";a="54835674" Received: from out3.smtp.messagingengine.com ([66.111.4.27]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/ADH-AES256-SHA; 10 Jul 2010 14:41:40 +0200 Received: from compute1.internal (compute1.internal [10.202.2.41]) by gateway1.messagingengine.com (Postfix) with ESMTP id 5B8FB16BA51 for ; Sat, 10 Jul 2010 08:41:39 -0400 (EDT) Received: from heartbeat1.messagingengine.com ([10.202.2.160]) by compute1.internal (MEProxy); Sat, 10 Jul 2010 08:41:39 -0400 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:content-transfer-encoding:in-reply-to; s=smtpout; bh=oM0bhN9A632XM+riHsm18/Di5z0=; b=cy7AJrsDmuWClOtP++138qovNisSzhAt7bFDHKJKU6umUlNLuyLuJ2lNva4mHoZH+PZ/WRuj6BDmBIa4wrl6LdGd1HkoLEcW4rWWn3dYNxnhFTHz9wCUHvGlgzKetBxIL7DRc29ilydcwA7c6X25SYu7AD0UsbcZiqgU3O9RXT4= X-Sasl-enc: qAvNufi09S8H/VnVa5Tl5gJrURK1AdBlhsQXzBk+vbMi 1278765699 Received: from localhost (unknown [69.86.121.157]) by mail.messagingengine.com (Postfix) with ESMTPSA id 040754D0CC6 for ; Sat, 10 Jul 2010 08:41:38 -0400 (EDT) Date: Sat, 10 Jul 2010 08:42:28 -0400 From: Jim Pryor To: caml-list@yquem.inria.fr Subject: Re: How public is Num.Nat Message-ID: <20100710124228.GD2772@vaio.earthlink.net> References: <7d8707de0811070133s5b4b8b36kd514eadb0be8a78f@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <7d8707de0811070133s5b4b8b36kd514eadb0be8a78f@mail.gmail.com> User-Agent: Mutt/1.5.20 (2009-06-14) X-Spam: no; 0.00; nat:01 nat:01 ocaml:01 dynlink:01 0100,:01 andrej:01 ocaml-only:01 integers:01 ocaml:01 mpfr:01 rewriting:01 wrote:01 heap:01 cma:01 int:01 Hi I'm looking into wrapping the Nat module from the Num package. I can't find any documentation for it, but the source + a bit of guesswork makes it somewhat accessible. However, superficially at least it looks like this library enables arbitrary getting/setting of bytes in the program's heap, with no bounds checking. Please tell me it's not so! $ ocaml dynlink.cma Objective Caml version 3.12.0+beta1 # #require "num";; # open Nat;; # let nx = nat_of_int 3;; # let dump () = List.map (fun x -> nth_digit_nat nx x) [0;1;2;3;4;5;6;7;8];; # dump ();; - : int list = [3; 1024; 1; 3074; 139752628822496; 1; 139752628800520; 1024; 1] # set_digit_nat nx 6 111999111; nth_digit_nat nx 6;; - : int = 111999111 # dump();; - : int list = [3; 1024; 1; 3074; 139752628822496; 1; 111999111; 1024; 1] I found this old message in the mailing list, but it seems to have gotten no answer: On Fri, Nov 07, 2008 at 10:33:41AM +0100, Andrej Bauer wrote: > The Nat module in the Num library is not documented in the official > documentation, but is documented in the 1992 tech report by Valérie > Ménissier-Morain. I would ilke to use Ocaml-only library for big > integers which has bit shifting operations. Big_int does not, but Nat > does. Is Nat stable and "safe to use" by people who are neither > French, nor at INRIA, nor are they Ocaml developers? > > Before someone tells me I should use GMP and/or MPFR: I am already > using them, I am just rewriting a piece of code so that it can be > optionally compiled with pure ocaml. -- Jim Pryor profjim@jimpryor.net