caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: james woodyatt <jhw@wetware.com>
To: Xavier Leroy <xavier.leroy@inria.fr>
Cc: The Trade <caml-list@inria.fr>
Subject: Re: [Caml-list] assert false and -noassert
Date: Wed, 20 Feb 2002 08:35:50 -0800	[thread overview]
Message-ID: <E627BF22-261F-11D6-AAF7-000502DB38F5@wetware.com> (raw)
In-Reply-To: <20020218150007.A20887@pauillac.inria.fr>

On Monday, February 18, 2002, at 06:00 , Xavier Leroy wrote:
> [I wrote:]
>> While we are on the subject of the assert function, it occurs to me 
>> that
>> it might be nice if -noassert together with "assert false" were to
>> bypass all exception handling and go right into program termination.  
>> It
>> seems to me that if I've used the -noassert option, I've made a promise
>> that the code compiled with it will never raise the Assert_failure
>> exception.
>
> This is a topic that we've discussed at some point: is it appropriate
> to map (conceptually) fatal errors (such as a failed assertion) to an
> exception?  There is one pitfall with this approach, namely that a
> catch-all "try ... with x -> ..." might inadvertently hide the fatal
> error.  On the other hand, the strenght of this approach is that it
> enables your program to clean up and possibly log a detailed error
> message before termination.

It *is* appropriate to map conceptually fatal errors (such as failed 
assertions) to exceptions.  I have a library.  It contains assertions.  
I want to test it.  I have a list of thirty test functions.  I iterate 
the list to apply all the functions to test the library, wrapping each 
one in a "try ... with x -> ..." clause.  Result: all thirty functions 
are applied, and I know how many of them raise the Assert_failure 
exception.

At some point, I want to turn off the assertions.  My expectation is 
that -noassert would then compile the library so that it never raises 
the Assert_failure exception.  Unfortunately, the "assert false" case 
is... well, an exception to the general rule.

That's why, when the -noassert flag is used, I would prefer that "assert 
false" map to an immediate program termination, á la "abort()" in the C 
language.  In fact, if that's what ocamlopt inserted in this case, i.e. 
a call to abort() in the C library, I would find that optimal.


--
j h woodyatt <jhw@wetware.com>
"...the antidote to misinformation is more information, not less."
                                                      --vinton cerf

-------------------
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


  reply	other threads:[~2002-02-20 16:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-15 17:01 [Caml-list] assertions and branch prediction james woodyatt
2002-02-18 14:00 ` Xavier Leroy
2002-02-20 16:35   ` james woodyatt [this message]
2002-02-24  9:08     ` [Caml-list] assert false and -noassert Mattias Waldau
2002-02-25 20:00       ` james woodyatt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E627BF22-261F-11D6-AAF7-000502DB38F5@wetware.com \
    --to=jhw@wetware.com \
    --cc=caml-list@inria.fr \
    --cc=xavier.leroy@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).