From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA19113 for caml-redistribution; Mon, 1 Dec 1997 11:18:25 +0100 (MET) Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA19058; Mon, 1 Dec 1997 11:17:25 +0100 (MET) From: Pierre Weis Message-Id: <199712011017.LAA19058@pauillac.inria.fr> Subject: Re: Assert_failure exception In-Reply-To: <199712010149.UAA02524@cmpsci13.cs.umass.edu> from "Adam P. Jenkins" at "Nov 30, 97 08:49:51 pm" To: ajenkins@cs.umass.edu (Adam P. Jenkins) Date: Mon, 1 Dec 1997 11:17:25 +0100 (MET) Cc: caml-list@pauillac.inria.fr MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: weis > Date: Sun, 30 Nov 1997 20:49:51 -0500 > From: "Adam P. Jenkins" > > I noticed that the Assert_failure exception is defined as > > exception Assert_failure of (string * int * int) > > but the arguments don't seem to be used for anything meaningful. More > importantly, the "assert" statement gives no indication of where it > was called from, or what expression it was called on. The argument of exception Assert_failure is used to report the file name and the characters that bound the assert statement in the file. > Since assert > seems to be a language level statement, it could actually set the > string argument of Assert_failure to a string representation of the > asserted expression when it fails. > > Now: > > # assert (1 = 2);; > Uncaught exception: Assert_failure(_) > > What I'd like to see: > > # assert (1 = 2);; > Uncaught exception: Assert_failure("1 = 2") > > Do you plan to add anything like this? For me, the fact that the > Assert_failure exception gives me no indication of where it was raised > makes me unlikely to use the assert statement. > > Sorry I can't post in French. > > Adam There should be a small ``misfeature'' in the toplevel interactive system that does not report properly the location of the assertion. If you use the compiler, you get lat: ~: cat tmp.ml assert ( 1 = 2 );; lat: ~: ocamlc tmp.ml lat: ~: a.out Fatal error: uncaught exception Assert_failure("tmp.ml", 0, 16) That's what you expected, no ? The modification you suggested could be interesting, although it seems to me to be strictly less powerful than the actual implementation of assert (assuming the toplevel misfeature be corrected). All the best, Pierre Weis INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/