From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 3953ABB91 for ; Sat, 23 Jul 2005 14:11:14 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j6NCBDsb017446 for ; Sat, 23 Jul 2005 14:11:13 +0200 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id OAA12165 for ; Sat, 23 Jul 2005 14:11:13 +0200 (MET DST) Received: from kraid.nerim.net (smtp-106-saturday.nerim.net [62.4.16.106]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j6NCBDaW017443 for ; Sat, 23 Jul 2005 14:11:13 +0200 Received: from [192.168.1.2] (xleroy.net1.nerim.net [62.212.116.147]) by kraid.nerim.net (Postfix) with ESMTP id 03A9E40E20; Sat, 23 Jul 2005 14:11:11 +0200 (CEST) Message-ID: <42E233DF.1050101@inria.fr> Date: Sat, 23 Jul 2005 14:11:11 +0200 From: Xavier Leroy User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Christian Lindig Cc: Caml List Subject: Re: [Caml-list] The 'restart' Bytecode References: <26df9c585c97ae7d4bc258277bd812e8@cs.uni-sb.de> In-Reply-To: <26df9c585c97ae7d4bc258277bd812e8@cs.uni-sb.de> X-Enigmail-Version: 0.91.0.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 42E233E1.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 42E233E1.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 bytecode:01 recursive:01 bytecode:01 ocaml:01 implements:01 preceded:01 pushes:01 stack:01 partial:01 tail:01 tail:01 executes:01 closure:02 closure:02 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 > 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