Browse thread
[Caml-list] Does Caml have slow arithmetics ?
-
Diego Olivier Fernandez Pons
- Richard Jones
-
Basile Starynkevitch [local]
- Diego Olivier Fernandez Pons
-
Evgeny Chukreev
-
Xavier Leroy
- Evgeny Chukreev
-
skaller
-
David Brown
- skaller
- Andreas Rossberg
- Alex Baretta
-
David Brown
- Jon Harrop
-
Xavier Leroy
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Richard Jones <rich@a...> |
| Subject: | Re: Tail calls (Was Re: [Caml-list] Does Caml have slow arithmetics ?) |
This discussion of tail calls is very interesting.
I understand what Xavier is saying about ocamlopt not optimizing badly
written code. Despite this, I have to say that ocamlopt does a
fantastic job!
However, I think there is one bit of badly written code where it would
be nice if the compiler could do a little bit more optimization,
namely functions such as:
let rec input_all_lines chan =
try
let line = input_line chan in
line :: input_all_lines chan
with
End_of_file -> []
The reason is that (as discussed previously, so please don't repost)
the tail-recursive version of this sort of code is quite a bit more
complicated, and therefore quite a bit harder to remember.
Note that the specific input_all_lines function should be in a library
- it is in ExtLib, I think. However I use that code /pattern/ quite
frequently, particularly when iterating over something which can throw
a Not_found or End_of_file exception and building a structure from the
result. So I need to remember the optimized version of the pattern,
which my poor brain can't do.
Rich.
--
Richard Jones. http://www.annexia.org/ http://www.j-london.com/
Merjis Ltd. http://www.merjis.com/ - improving website return on investment
MOD_CAML lets you run type-safe Objective CAML programs inside the Apache
webserver. http://www.merjis.com/developers/mod_caml/
-------------------
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