caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: basile@starynkevitch.net
To: "Erik de Castro Lopo" <ocaml-erikd@mega-nerd.com>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Reporting on sucess/failure of tail recursion
Date: Fri, 2 Dec 2005 10:29:48 +0100 (CET)	[thread overview]
Message-ID: <55541.132.166.133.216.1133515788.squirrel@panel.lost-oasis.net> (raw)
In-Reply-To: <20051202200957.2fb14d49.ocaml-erikd@mega-nerd.com>



> Say I have a file containing a number of Ocaml functions.

> We all know the advantages of tail recursive functions over non-tail
> recursive ones and some of us know if a simple function is tail
> recursice just by looking at it. However, for more complex functions
> it would be really nice if there was a compiler mode that could print
> which recursive functions in a file were tail recursive and which were
> not.

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.

Maybe what you are dreaming of is an extension of the -dtypes flag (to
ocamlc) which not only computes the type of each expression,
but also flags each function *call* as a tail (or not a tail) call. I do
agree it would be quite useful (but my knowledge of ocaml internals make
me think that it is in principle easy, but in practice would require a lot
of changes within the compiler, since tail-rec detection is done in passes
near the backend, after the typing.).

We could even dream of a let tailrec language construct which behaves like
let rec but checks that each recursive call to the function is in fact a
tail-recursion.

All this is in principle easy to do, but I understand that it might
require a significant amount of work which is not the priority of INRIA
Cristal team (which is a team of researchers, not of engineers).

Regards.


-- 
Basile Starynkevitch http://starynkevitch.net/Basile

PS: I've currently got ADSL problems so have difficulties to read my emails.








  parent reply	other threads:[~2005-12-02  9:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-02  9:09 Erik de Castro Lopo
2005-12-02  9:13 ` [Caml-list] " Jonathan Roewen
2005-12-02  9:25   ` Erik de Castro Lopo
2005-12-02  9:29 ` basile [this message]
2005-12-02 10:16   ` Erik de Castro Lopo
2005-12-02 15:17     ` Jean-Christophe Filliatre
2005-12-02 23:58       ` skaller
2005-12-02 10:45   ` David MENTRE
2005-12-03  0:28 David Thomas
2005-12-04  4:11 ` Andres Varon

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=55541.132.166.133.216.1133515788.squirrel@panel.lost-oasis.net \
    --to=basile@starynkevitch.net \
    --cc=caml-list@yquem.inria.fr \
    --cc=ocaml-erikd@mega-nerd.com \
    /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).