From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id OAA20894; Mon, 18 Feb 2002 14:34:42 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id OAA20480 for ; Mon, 18 Feb 2002 14:34:41 +0100 (MET) Received: from t2.fast.net.uk (ns1.fast.net.uk [212.42.162.2]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g1IDYf522750; Mon, 18 Feb 2002 14:34:41 +0100 (MET) Received: from htec.demon.co.uk (adsl-212-42-169-63.fast.net.uk [212.42.169.63]) by t2.fast.net.uk (8.11.6/8.11.4) with ESMTP id g1IDYWW40859; Mon, 18 Feb 2002 13:34:32 GMT Message-ID: <3C71046D.7090409@htec.demon.co.uk> Date: Mon, 18 Feb 2002 13:41:01 +0000 From: Christopher Quinn User-Agent: Mozilla/5.0 (compatible; MSIE5.5; Windows 98; X-Accept-Language: en-us MIME-Version: 1.0 To: Damien Doligez CC: caml-list@inria.fr Subject: Re: [Caml-list] assertions and branch prediction References: <200202171347.OAA0000013262@beaune.inria.fr> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk May I ask how | _ -> assert (not true); () is different from | _ -> assert false; () ??? Thanks, chris Damien Doligez wrote: >>From: james woodyatt >> > >> match p with >> | A -> ...; () >> | B -> ...; () >> | _ -> assert false >> >>Then I hit upon the idea of rewriting it this way: >> >> assert (p = A || p = B); >> match p with >> | A -> ...; () >> | B -> ...; () >> | C -> () >> >>My thinking was that I would rather pay up front with a more expensive >>assertion, one that can be stripped out later with the -noassert option, >>rather than pay at deployment with code (for raising the Assert_failure >>exception) that I've eventually proven will not be executed. >> > >You can have the best of both worlds by writing it like this: > > match p with > | A -> ...; () > | B -> ...; () > | _ -> assert (not true); () > > >As for "assert false" with -noassert, you're not really supposed to >catch the Assert_failure exception (unless you really know what >you're doing), so it should result in the immediate termination of >your program anyway. > >-- Damien >------------------- >Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ >To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr > -- rgrds, Chris Quinn ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr