Browse thread
[Caml-list] Int overflow in literals
-
Marcin 'Qrczak' Kowalczyk
- Alex Baretta
- Issac Trotts
- Xavier Leroy
[
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: | Xavier Leroy <xavier.leroy@i...> |
| Subject: | Re: [Caml-list] Int overflow in literals |
> 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? - Xavier Leroy ------------------- 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