caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Xavier Leroy <Xavier.Leroy@inria.fr>
To: Christian Lindig <lindig@cs.uni-sb.de>
Cc: Caml List <caml-list@inria.fr>
Subject: Re: [Caml-list] The 'restart' Bytecode
Date: Sat, 23 Jul 2005 14:11:11 +0200	[thread overview]
Message-ID: <42E233DF.1050101@inria.fr> (raw)
In-Reply-To: <26df9c585c97ae7d4bc258277bd812e8@cs.uni-sb.de>

> To verify that some function is indeed tail recursive I sometimes
> inspect its bytecode using "ocaml -dinstr". The 'appterm' instruction
> implements the desired tail call and thus is what I am looking for.
> However, sometimes the appterm instruction is followed by a restart
> instruction.

The "restart" is actually part of the following function.  "grab"
instructions that mark the beginning of a multiple-argument function
are always preceded by a "restart" instruction.  If not enough
arguments are provided to the function, "grab" returns a closure
pointing to the preceding "restart" instruction and containing the
values of the provided arguments.  When this partial application
closure is applied, "restart" executes, pushes back the saved
arguments on the stack, and reexecutes (by falling through) the "grab"
instruction.

So, nothing to worry about concerning tail calls.

- Xavier Leroy


      reply	other threads:[~2005-07-23 12:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-20 10:47 Christian Lindig
2005-07-23 12:11 ` Xavier Leroy [this message]

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=42E233DF.1050101@inria.fr \
    --to=xavier.leroy@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=lindig@cs.uni-sb.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).