Browse thread
Reporting on sucess/failure of tail recursion
[
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: | Erik de Castro Lopo <ocaml-erikd@m...> |
| Subject: | Re: [Caml-list] Reporting on sucess/failure of tail recursion |
basile@starynkevitch.net wrote:
> Functions are not tail-recursive, but function *calls* are (or not)
> tail-recursive. I mean that a given function may have both tail
> [-recursive]
> and non-tail [-recursive] calls.
Ok, so many recursive functions are actually written like:
let fact n =
let rec sub_fact curr acc =
if curr > n then acc
else sub_fact (curr + 1) (curr * acc)
in
sub_fact 1 1
with a no-recursive outer function and a tail recursive inner function.
It would still be nice to know if the inner function is tail recursive.
> Maybe what you are dreaming of is an extension of the -dtypes flag (to
> ocamlc)
Ooo, I didn't know about -dtypes. That might be useful. Thanks.
Yes, something like -dtypes.
Erik
--
+-----------------------------------------------------------+
Erik de Castro Lopo
+-----------------------------------------------------------+
"That being done, all you have to do next is call free() slightly
less often than malloc(). You may want to examine the Solaris
system libraries for a particularly ambitious implementation of
this technique."
-- Eric O'Dell (comp.lang.dylan)