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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 7FD72BBAF for ; Tue, 24 Aug 2010 08:53:47 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AmwHAP0Ic0zNm0EP/2dsb2JhbACTKooSgwFxuUeFNwSENYVDgm8 X-IronPort-AV: E=Sophos;i="4.56,261,1280700000"; d="scan'208";a="57720590" Received: from virginia.nps.edu ([205.155.65.15]) by mail2-smtp-roc.national.inria.fr with ESMTP; 24 Aug 2010 08:53:46 +0200 Received: from Adric.ern.nps.edu ([172.20.216.170]) by virginia.nps.edu with Microsoft SMTPSVC(6.0.3790.4675); Mon, 23 Aug 2010 23:53:44 -0700 Received: by Adric.ern.nps.edu (Postfix, from userid 760) id 620E517415; Mon, 23 Aug 2010 23:53:11 -0700 (PDT) From: oleg@okmij.org To: padator@wanadoo.fr Cc: caml-list@inria.fr In-reply-to: <72B69466-3FAC-41AC-96ED-6024DCBD341A@wanadoo.fr> Subject: Generators in OCaml Message-Id: <20100824065311.620E517415@Adric.ern.nps.edu> Date: Mon, 23 Aug 2010 23:53:11 -0700 (PDT) X-OriginalArrivalTime: 24 Aug 2010 06:53:44.0387 (UTC) FILETIME=[17FE1930:01CB4359] X-Spam: no; 0.00; oleg:01 ocaml:01 delimited:01 delimited:01 monadic:01 style':98 style':98 wrote:01 computation:01 cps:02 python:03 seems:03 programming:03 library:03 tutorial:03 Yoann Padioleau wrote: > Is there any tutorial on why such features are useful ? > Concrete examples of their use. Thank you for the question! I think you may find many examples of delimited continuations on the following web site: http://okmij.org/ftp/Computation/Continuations.html Notable examples are the probabilistic programming language HANSEI, normalization of MapReduce bodies by evaluation, and a framework to program CGI applications in `direct style' (as if they were regular console applications). Delimited continuations proved quite useful for writing code generators: to perform let- or if-insertions in the generated code, one has two choices: write the generator in a monadic style or CPS, or use a `direct style' relying on delimited control. Experience seems to show that direct-style generators are more perspicuous. > For instance can you implement python generators and its yield stuff > by using this library ? Yes! Here is the complete code http://okmij.org/ftp/ML/generator.ml