caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] More or bignums/ints
@ 2004-06-11 19:38 John Hughes
  2004-06-12  0:09 ` Jacques Garrigue
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: John Hughes @ 2004-06-11 19:38 UTC (permalink / raw)
  To: caml-list

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


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

end of thread, other threads:[~2004-06-23 14:51 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-11 19:38 [Caml-list] More or bignums/ints John Hughes
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

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).