From: "Bünzli Daniel" <daniel.buenzli@erratique.ch>
To: Andrej.Bauer@andrej.com
Cc: caml-list List <caml-list@inria.fr>
Subject: Re: [Caml-list] [OSR] Exceptionless error management
Date: Thu, 31 Jan 2008 21:03:58 +0100 [thread overview]
Message-ID: <B5C1FEA6-3C5C-4E58-8A1E-08E599BAAB93@erratique.ch> (raw)
In-Reply-To: <47A1D68B.70700@fmf.uni-lj.si>
Le 31 janv. 08 à 15:09, Andrej Bauer a écrit :
> I have become to prefer option types as return values (as opposed to
> exceptions), but I admit it can be annoying to always consider both
> possibilities, especially if you know that "None" won't happen.
Maybe it is a point of view, you are fed up of considering both
possibilites while I'm personally fed up of writing
match try Some (f x) with e -> None with
| None -> ..
| Some v -> ...
Because I need tail recursive functions.
> If the library only provides "find" that returns an option type, the
> above solution gets around constant checking. But how much runtime
> overhead does it cause? Has anyone measured that?
No idea. Unscientific benchmark at the end of the email.
> What is wrong with having two functions?
You have to choose. You don't have exceptionless error mangement
anymore which is the point of the proposal. As the module developer I
don't want to write two functions to do the same thing albeit in a
slight different way one of which strikes me as the being the wrong way.
Best,
Daniel
osx 10.5.1 1ghz G4 512 ram
> cat in.ml
let () =
let f = ref [] in
try while (true) do f := (input_line stdin) :: !f done
with End_of_file -> ignore (!f)
> cat inb.ml
let () =
let rec next acc =
match try Some (input_line stdin) with End_of_file -> None with
| None -> acc
| Some l -> next (l :: acc)
in
ignore (next [])
> ocamlbuild in.native inb.native
Finished, 8 targets (0 cached) in 00:00:01.
> time jot 1000000 | ./in.native
real 0m4.814s
user 0m4.371s
sys 0m0.218s
> time jot 1000000 | ./inb.native
real 0m4.790s
user 0m4.355s
sys 0m0.217s
next prev parent reply other threads:[~2008-01-31 20:03 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-31 8:55 Bünzli Daniel
2008-01-31 9:57 ` [Caml-list] " Till Varoquaux
2008-01-31 11:01 ` Bünzli Daniel
2008-01-31 14:09 ` Andrej Bauer
2008-01-31 14:16 ` Michael Ekstrand
2008-01-31 19:28 ` David Teller
2008-01-31 19:59 ` Michael Ekstrand
2008-01-31 20:05 ` blue storm
2008-01-31 20:03 ` Bünzli Daniel [this message]
2008-01-31 20:25 ` David Teller
2008-01-31 20:40 ` David Teller
2008-01-31 21:16 ` Bünzli Daniel
2008-01-31 21:31 ` David Teller
2008-01-31 21:35 ` Jon Harrop
2008-01-31 22:01 ` Christophe Raffalli
2008-02-01 7:27 ` Michaël Grünewald
2008-02-01 7:47 ` Bünzli Daniel
2008-02-01 10:50 ` Till Varoquaux
2008-02-01 11:31 ` Bünzli Daniel
2008-02-01 15:59 ` Vincent Hanquez
2008-02-01 18:37 ` Bünzli Daniel
2008-02-01 19:43 ` Vincent Hanquez
2008-02-01 16:04 ` David Allsopp
2008-02-01 8:31 ` David Teller
2008-02-01 12:19 ` Yaron Minsky
2008-02-05 10:00 ` David Teller
2008-02-05 10:12 ` Vincent Hanquez
2008-02-05 10:26 ` Bünzli Daniel
2008-02-05 11:06 ` Vincent Hanquez
2008-02-05 13:46 ` Jon Harrop
2008-02-05 11:36 ` Frédéric van der Plancke
2008-02-06 8:45 ` Michaël Grünewald
2008-02-08 13:09 ` Bünzli Daniel
2008-02-05 14:12 ` David Teller
2008-02-11 8:12 ` David Teller
2008-02-11 9:09 ` Bünzli Daniel
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=B5C1FEA6-3C5C-4E58-8A1E-08E599BAAB93@erratique.ch \
--to=daniel.buenzli@erratique.ch \
--cc=Andrej.Bauer@andrej.com \
--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