caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "John Hughes" <jfh@cs.brown.edu>
To: <caml-list@inria.fr>
Subject: [Caml-list] More or bignums/ints
Date: Fri, 11 Jun 2004 21:38:29 +0200	[thread overview]
Message-ID: <20040611193818.0A43457251@twix.cs.brown.edu> (raw)

I've read the May interchange in CWN that started with the question

> I have made a web search to understand which kind of support for 
> bignums is available for OCaml...

and found it interesting. I'll be teaching a few weeks of ML as part 
of a first-year course at Brown University, and we've used SML in 
previous years. SML/NJ works OK, but we'd like a debugger, so I've 
looked at OCaml as a possible alternative. I was a little depressed 
to find (by trial and error) that "int" doesn't mean "integer" but 
rather "element of Z/nZ for some very large n, represented with 
integer notation, including negative signs." 

I think I can live with this if only there's some way to write 
something like this (pseudo-ML/Java):

fun fact(0) = 1
  | fact(n) = try {
                 n * fact(n-1)
              }
              catch (IntegerOverflow e) ...


What I don't think I can bear is to use the sorts of "bignum"-like 
libraries that make me write things like

 y = x bigadd big-unit

to mean 

 y = x + 1

because our students will actually be writing some code that has 
a good deal of arithmetic in it. 

---

So the questions are

1. Is there a way to catch overflow exceptions within an entire 
   computation?
2. Is there a way to tell OCaml that ints really are either 
   (a) bignums or
   (b) overflow-protected ints (as in SML/NJ, for instance)

Perhaps the implicit third question is

3. Is there a reasonable debugger for some dialect of ML that has 
what I might call "protected integers"? 

Thanks very much in advance. 

-John Hughes

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


             reply	other threads:[~2004-06-11 19:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-11 19:38 John Hughes [this message]
2004-06-12  0:09 ` Jacques Garrigue
2004-06-14 15:37 ` Brian Hurt
2004-06-14 16:17   ` Andreas Rossberg
2004-06-14 15:55 ` Xavier Leroy
2004-06-15 22:45   ` Manos Renieris
2004-06-15 20:26 ` Brian Hurt
2004-06-15 20:36   ` Brian Hurt
2004-06-23 10:50   ` John Hughes
2004-06-23 14:51     ` skaller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040611193818.0A43457251@twix.cs.brown.edu \
    --to=jfh@cs.brown.edu \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).