caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* How public is Num.Nat
@ 2008-11-07  9:33 Andrej Bauer
  2010-07-10 12:42 ` Jim Pryor
  0 siblings, 1 reply; 3+ messages in thread
From: Andrej Bauer @ 2008-11-07  9:33 UTC (permalink / raw)
  To: caml-list

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.

Best regards,

Andrej

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How public is Num.Nat
  2008-11-07  9:33 How public is Num.Nat Andrej Bauer
@ 2010-07-10 12:42 ` Jim Pryor
  2010-07-10 14:56   ` [Caml-list] " Jim Pryor
  0 siblings, 1 reply; 3+ messages in thread
From: Jim Pryor @ 2010-07-10 12:42 UTC (permalink / raw)
  To: caml-list

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] Re: How public is Num.Nat
  2010-07-10 12:42 ` Jim Pryor
@ 2010-07-10 14:56   ` Jim Pryor
  0 siblings, 0 replies; 3+ messages in thread
From: Jim Pryor @ 2010-07-10 14:56 UTC (permalink / raw)
  To: caml-list

On Sat, Jul 10, 2010 at 08:42:28AM -0400, Jim Pryor wrote:
> 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!

I found the documentation from 1992 here:
ftp://ftp.inria.fr/INRIA/publication/publi-pdf/RT/RT-0141.pdf

Not quite the same location listed in Ch 22 of the ref manual, but not
too far off, either. It seems that what I observed is indeed the documented
behavior of the Nat module. The Big_int and Num modules hide that
nastiness away.

-- 
Jim Pryor
profjim@jimpryor.net


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-07-10 14:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-07  9:33 How public is Num.Nat Andrej Bauer
2010-07-10 12:42 ` Jim Pryor
2010-07-10 14:56   ` [Caml-list] " Jim Pryor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).