From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id AB299BC0A for ; Thu, 5 Apr 2007 22:40:29 +0200 (CEST) Received: from ptb-relay01.plus.net (ptb-relay01.plus.net [212.159.14.212]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l35KeS2D021638 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for ; Thu, 5 Apr 2007 22:40:29 +0200 Received: from [80.229.56.224] (helo=beast.local) by ptb-relay01.plus.net with esmtp (Exim) id 1HZYks-0005PW-VT for caml-list@yquem.inria.fr; Thu, 05 Apr 2007 21:40:27 +0100 From: Jon Harrop Organization: Flying Frog Consultancy Ltd. To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Generators/iterators and lazy evaluation? Date: Thu, 5 Apr 2007 21:35:32 +0100 User-Agent: KMail/1.9.5 References: <200704050053.41426.jon@ffconsultancy.com> <46149010.30505@inria.fr> In-Reply-To: <46149010.30505@inria.fr> MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200704052135.32683.jon@ffconsultancy.com> Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 46155EBD.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; frisch:01 ocaml:01 ocaml:01 frog:98 iterators:01 wrote:01 wrote:01 caml-list:01 explicitly:01 alain:01 lazy:02 cps:02 python:02 python:02 idiomatic:02 On Thursday 05 April 2007 06:58, Alain Frisch wrote: > Jon Harrop wrote: > > The moral is: don't try to write idiomatic Python in OCaml. > > I think the moral is rather: read the OP's email more carefully. He > doesn't want to translate some Python examples into OCaml by hand, he > wants to implement a Python interpreter in OCaml. My mistake. In that case, I agree that CPS is the obvious solution. Perhaps it is possible to do something equivalent by explicitly storing the state and "program counter" in the function when yield is called? -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. OCaml for Scientists http://www.ffconsultancy.com/products/ocaml_for_scientists