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 LAA10576; Thu, 10 Jun 2004 11:06:00 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id LAA10163 for ; Thu, 10 Jun 2004 11:05:59 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i5A95pEV019599; Thu, 10 Jun 2004 11:05:51 +0200 Received: from bourg.inria.fr (bourg.inria.fr [128.93.11.100]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id LAA10807; Thu, 10 Jun 2004 11:05:51 +0200 (MET DST) Received: from basile by bourg.inria.fr with local (Exim 4.34) id 1BYLUv-0001p8-5e; Thu, 10 Jun 2004 11:05:21 +0200 Date: Thu, 10 Jun 2004 11:05:21 +0200 To: Diego Olivier Fernandez Pons , caml-list@inria.fr Subject: Re: [Caml-list] Assert fail in partial application Message-ID: <20040610090520.GA6967@bourg.inria.fr> References: Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.6+20040523i From: "Basile Starynkevitch [local]" X-Miltered: at nez-perce with ID 40C8246F.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 basile:01 basile:01 2004:99 pons:01 val:01 implemented:01 camlp:01 fernandez:01 cristal:01 cristal:01 int:01 int:01 0200,:01 olivier:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hello All, On Thu, Jun 10, 2004 at 10:43:06AM +0200, Diego Olivier Fernandez Pons wrote: > > I would like a function that contains an assert to fail in partial > application and the test are still removed when compiling in noassert > mode > > # let f = fun x y -> assert (x > 0); assert (y > 0); x + y > val f : int -> int -> int > # f 0;; > - : int -> int = > # f 0 0;; > Exception: Assert_failure (" ", 1, 19). > assert is only a syntactical sugar for if then () else raise Assert_failure () You might try to code let f = fun x -> begin assert(x>0); fun y -> begin assert(y>0); x + y end end;; # f 0;; Exception: Assert_failure ("", 4, 7). # f 1;; - : int -> int = # f 1 2;; - : int = 3 # f 1 0;; Exception: Assert_failure ("", 6, 9). Assert has nothing magic (except that it passes the file position to the Assert+failure exception). It could be implemented as a camlp4 macro. Regards. -- Basile STARYNKEVITCH -- basile dot starynkevitch at inria dot fr Project cristal.inria.fr - (temporarily) http://cristal.inria.fr/~starynke --- all opinions are only mine ------------------- 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