From: Pierre Weis <email@example.com>
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: firstname.lastname@example.org (Adam P. Jenkins)
Date: Mon, 1 Dec 1997 11:17:25 +0100 (MET)
> Date: Sun, 30 Nov 1997 20:49:51 -0500
> From: "Adam P. Jenkins" <email@example.com>
> 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.
> # 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.
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,
INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/
This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:13 MET