Exceptions inside assertions

From: Gerd Stolpmann (Gerd.Stolpmann@darmstadt.netsurf.de)
Date: Wed Nov 10 1999 - 01:06:57 MET


From: Gerd Stolpmann <Gerd.Stolpmann@darmstadt.netsurf.de>
To: caml-list@inria.fr
Subject: Exceptions inside assertions
Date: Wed, 10 Nov 1999 01:06:57 +0100
Message-Id: <99111001200402.23873@ice>

Hi,

I have a problem with exceptions which are raised within the expression of an
assertion, e.g.

assert (raise Not_found)

The current behaviour is that the exception "falls through the assertion" which
may not be appropriate for some cases. For example, consider

assert (Queue.peek queue == current_element)

>From my point of view, the assertion expresses that "queue" has at least one
element and that this element is identical to "current_element". But if the
assertion is violated because the queue is empty, I only get a Queue.Empty
exception, and I do not see the reason for it. Perhaps I even catch
Queue.Empty, and the program continues, which is very hard to find out.

I suggest to introduce a new Assert_failure_by_exception exception to better
report this situation.

Gerd

--
----------------------------------------------------------------------------
Gerd Stolpmann      Telefon: +49 6151 997705 (privat)
Viktoriastr. 100             
64293 Darmstadt     EMail:   Gerd.Stolpmann@darmstadt.netsurf.de (privat)
Germany                     
----------------------------------------------------------------------------



This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:28 MET