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=none autolearn=disabled version=3.1.3 Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 68F5DBC0A for ; Wed, 4 Apr 2007 23:37:25 +0200 (CEST) Received: from smtp.syd.people.net.au (smtp.syd.people.net.au [218.214.225.98]) by discorde.inria.fr (8.13.6/8.13.6) with SMTP id l34LbMmt003164 for ; Wed, 4 Apr 2007 23:37:24 +0200 Received: (qmail 5753 invoked from network); 4 Apr 2007 21:37:22 -0000 Received: from unknown (HELO coltrane.mega-nerd.net) (218.214.64.136) by smtp.syd.people.net.au with SMTP; 4 Apr 2007 21:37:22 -0000 Received: from coltrane (coltrane [192.168.1.101]) by coltrane.mega-nerd.net (Postfix) with SMTP id 160D57ADA for ; Thu, 5 Apr 2007 07:37:21 +1000 (EST) Date: Thu, 5 Apr 2007 07:37:20 +1000 From: Erik de Castro Lopo To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Generators/iterators and lazy evaluation? Message-Id: <20070405073720.b21665c8.mle+ocaml@mega-nerd.com> In-Reply-To: <20070405071652.bcb9be46.mle+ocaml@mega-nerd.com> References: <46140EB5.50700@inria.fr> <20070405071652.bcb9be46.mle+ocaml@mega-nerd.com> Organization: Erik Conspiracy Secret Labs X-Mailer: Sylpheed version 2.3.0beta5 (GTK+ 2.8.20; i486-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Miltered: at discorde with ID 46141A92.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 frisch:01 iterator:01 runtime:01 threads:01 computations:01 stack:01 python's:01 posix:01 threads:01 python's:01 ocaml:01 comedy:98 gimmicks:98 iterators:01 Erik de Castro Lopo wrote: > Alain Frisch wrote: > > > I think you cannot implement this notion of iterator without some kind > > of control flow operator (at runtime) or some code rearrangement (at > > compile time). The point is that you must mainting several active > > "threads" of computations, including their own stack. > > Alain, I think you may have misunderstood Python's yeild operator. > Typically the original poster's pow2 generators would be used like: > > for p = pow2 (10): > print p I should add, that when the yeild operator is used in Python, there is no separate thread of execution like there would be for say pthead_yeild() in POSIX threads. Python's yeild is very much closer to Lazy evaluation in Ocaml. Erik -- +-----------------------------------------------------------+ Erik de Castro Lopo +-----------------------------------------------------------+ "The RIAA is obsessed to the point of comedy with the frustration of having its rules broken, without considering whether such rules might be standing in the way of increased revenues. Indeed, Napster and Gnutella may turn out to be the two best music-marketing gimmicks yet devised, if only the RIAA would take its head out of its ass long enough to realise it." -- Thomas C Greene on www.theregister.co.uk