From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id RAA18143; Fri, 31 Oct 2003 17:56:31 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id RAA18129 for ; Fri, 31 Oct 2003 17:56:30 +0100 (MET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h9VGgI124221; Fri, 31 Oct 2003 17:42:20 +0100 (MET) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id RAA17725; Fri, 31 Oct 2003 17:42:15 +0100 (MET) Date: Fri, 31 Oct 2003 17:42:15 +0100 From: Xavier Leroy To: "Marcin 'Qrczak' Kowalczyk" Cc: caml-list@inria.fr Subject: Re: [Caml-list] Int overflow in literals Message-ID: <20031031174215.A17345@pauillac.inria.fr> References: <1067522012.5880.6.camel@qrnik> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: <1067522012.5880.6.camel@qrnik>; from qrczak@knm.org.pl on Thu, Oct 30, 2003 at 02:53:32PM +0100 X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 emits:01 emits:01 inclined:01 imho:01 int:01 int:01 arithmetic:01 writes:01 overflow:02 overflow:02 literals:02 literals:02 exception:02 modulo:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > 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