From: "Basile Starynkevitch [local]" <basile.starynkevitch@inria.fr>
To: Diego Olivier Fernandez Pons <Diego.FERNANDEZ_PONS@etu.upmc.fr>,
caml-list@inria.fr
Subject: Re: [Caml-list] Assert fail in partial application
Date: Thu, 10 Jun 2004 11:05:21 +0200 [thread overview]
Message-ID: <20040610090520.GA6967@bourg.inria.fr> (raw)
In-Reply-To: <Pine.A41.4.44.0406011215140.1810462-100000@ibm1>
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 = <fun>
> # f 0 0;;
> Exception: Assert_failure (" ", 1, 19).
>
assert is only a syntactical sugar for if <asserted-condition> then ()
else raise Assert_failure (<sourcefileposition>)
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 = <fun>
# 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
next prev parent reply other threads:[~2004-06-10 9:06 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-06-10 8:43 Diego Olivier Fernandez Pons
2004-06-10 9:05 ` Basile Starynkevitch [local] [this message]
2004-06-10 9:15 ` Diego Olivier Fernandez Pons
2004-06-10 15:04 ` Richard Jones
2004-06-17 8:32 ` Jean-Christophe Filliatre
2004-06-17 13:13 ` Damien Doligez
2004-06-10 9:05 ` Benjamin Monate
2004-06-10 9:10 ` Olivier Andrieu
2004-06-10 9:10 ` Christophe TROESTLER
2004-06-10 20:56 ` Brian Hurt
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=20040610090520.GA6967@bourg.inria.fr \
--to=basile.starynkevitch@inria.fr \
--cc=Diego.FERNANDEZ_PONS@etu.upmc.fr \
--cc=caml-list@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).