caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Julien Moutinho <julien.moutinho@gmail.com>
To: Oliver Bandel <oliver@first.in-berlin.de>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Warning on not-tail recursive functions
Date: Sat, 4 Aug 2007 15:26:22 +0200	[thread overview]
Message-ID: <20070804132621.GA5804@jiyu.gnu> (raw)
In-Reply-To: <1186230861.46b4724d1561e@webmail.in-berlin.de>

On Sat, Aug 04, 2007 at 02:34:21PM +0200, Oliver Bandel wrote:
> Zitat von Brian Hurt <bhurt@spnz.org>:
> > On Sat, 4 Aug 2007, tmp123@menta.net wrote:
> > > 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.
Ibid.

> > 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.
I agree Mr.Hurt.

> Does ignore REALLY ignore the values (does not generate them), so that
> this call is like a true tail-call,
No, [ignore] is not a macro, so it always triggers the calculation of its argument.
Think about ignore as if it would be [let ignore _ = ()]
Note however that it is not truly the case, and that [ignore == ignore] is false,
since [ignore] is actually defined as an external value
[external ignore : 'a -> unit = "%ignore"]

> or will the maybe_tailcall
> generate and give back results to the ignore-call and then
> ignore throws away the stuff (then it would be NO tailcall).
Yes, AFAICS with the -S option, neither [ignore] nor [let _ = your_rec_fun in ()]
are segregated from the other functions to produce jumps.
And I perfectly understand that the Inrians work on more important
optimizations than those.


  reply	other threads:[~2007-08-04 13:26 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 ` [Caml-list] " Brian Hurt
2007-08-04 12:34   ` Oliver Bandel
2007-08-04 13:26     ` Julien Moutinho [this message]
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=20070804132621.GA5804@jiyu.gnu \
    --to=julien.moutinho@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=oliver@first.in-berlin.de \
    /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).