Browse thread
[Caml-list] Int overflow in literals
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Oleg Trott <oleg_trott@c...> |
| Subject: | Re: [Caml-list] Int overflow in literals |
On Friday 31 October 2003 11:42 am, Xavier Leroy wrote: > > I understand that int overflow is not checked on arithmetic for > > efficiency reasons, but IMHO it would be better if it was checked > > at least in literals. When someone writes 10000000000, he certainly > > does not mean -737418240. > > It caused confusion in a class when someone was interactively testing > > a function with larger and larger inputs. > > This is a very good suggestion. There are several ways to go about this: > > - The lexer emits a warning in case of overflow, and proceeds with > the value modulo the size of the type. > - The lexer emits an error on overflow. > - The int_of_string functions raise an exception on overflow. > > Based on the comments posted so far on this list, and on a quick > discussion with colleagues, I'm inclined toward the third approach > (int_of_string fails in case of overflow). Does anyone know of a use > scenario where this new behavior of int_of_string would be a problem? How much do you think the performance of "typical programs" would be affected (in percent) if +, - and * were also made to raise an exception on overflow? -- Oleg Trott <oleg_trott@columbia.edu> ------------------- 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