* Re: Assert_failure exception
[not found] <199712010149.UAA02524@cmpsci13.cs.umass.edu>
@ 1997-12-01 10:17 ` Pierre Weis
0 siblings, 0 replies; only message in thread
From: Pierre Weis @ 1997-12-01 10:17 UTC (permalink / raw)
To: Adam P. Jenkins; +Cc: caml-list
> Date: Sun, 30 Nov 1997 20:49:51 -0500
> From: "Adam P. Jenkins" <ajenkins@cs.umass.edu>
>
> 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/
^ permalink raw reply [flat|nested] only message in thread