English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
The 'restart' Bytecode
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-07-23 (12:11)
From: Xavier Leroy <Xavier.Leroy@i...>
Subject: Re: [Caml-list] The 'restart' Bytecode
> 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"

So, nothing to worry about concerning tail calls.

- Xavier Leroy