From: Brian Hurt <bhurt@spnz.org>
To: tmp123@menta.net
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Warning on not-tail recursive functions
Date: Sat, 4 Aug 2007 08:27:20 -0400 (EDT) [thread overview]
Message-ID: <Pine.LNX.4.64.0708040817060.20887@localhost> (raw)
In-Reply-To: <46B45BE3.9040403@menta.net>
On Sat, 4 Aug 2007, tmp123@menta.net wrote:
> Hello,
>
> Please, knows someone if "ocamlopt" can print a warning message when a
> recursive function is not tail recursive, and code with the "jmp"
> optimization has not been generated?.
The problem is that I often write recursive functions which are not tail
recursive, and that's OK. As an example, take a look at the join (or
filter) functions I wrote in priority queue implementation in my previous
email (subject line: "Sorted list"). They're not tail recursive, but
since they only go O(log N) deep, that's not a problem.
The rules for what is or is not tail recursive are pretty simple. Boiled
down, they are:
1) The tail call must not be within a try expression
2) You can not do anything except return, uninspected and unmodified, the
returned value from the call.
Given that the rules are simple and local, I can generally just tell, by
looking at the call, wether it's a tail call or not.
Brian
next prev parent reply other threads:[~2007-08-04 12:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-04 10:58 tmp123
2007-08-04 12:27 ` Brian Hurt [this message]
2007-08-04 12:34 ` [Caml-list] " Oliver Bandel
2007-08-04 13:26 ` Julien Moutinho
2007-08-04 14:52 ` Brian Hurt
2007-08-04 19:24 ` Oliver Bandel
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=Pine.LNX.4.64.0708040817060.20887@localhost \
--to=bhurt@spnz.org \
--cc=caml-list@yquem.inria.fr \
--cc=tmp123@menta.net \
/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