From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id KAA26582; Fri, 14 Mar 2003 10:06:00 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id KAA26969 for ; Fri, 14 Mar 2003 10:05:59 +0100 (MET) Received: from mail.exomi.com (mail.exomi.com [217.169.64.72]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h2E95wf15934 for ; Fri, 14 Mar 2003 10:05:58 +0100 (MET) Received: from exomi.com (oxy.exomi.com [10.0.20.56]) by mail.exomi.com (Postfix) with ESMTP id 858935D03; Fri, 14 Mar 2003 11:05:57 +0200 (EET) Date: Fri, 14 Mar 2003 11:05:56 +0200 Subject: Re: [Caml-list] OCaml popularity Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v551) Cc: caml-list@inria.fr To: "Daniel M. Albro" From: Ville-Pertti Keinonen In-Reply-To: <1047620947.1866.21.camel@giynz> Message-Id: <2ABB7A8B-55FC-11D7-8D68-000393863F70@exomi.com> Content-Transfer-Encoding: 7bit X-Mailer: Apple Mail (2.551) X-Spam: no; 0.00; caml-list:01 passing:01 ocaml:01 rec:01 continuation:02 essentially:02 recursive:03 tail:03 let:04 variation:04 ary:04 outer:04 anyway:05 loop:06 fun:08 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > Break simulated by continuation passing (I think that's > what this is -- it looks like a call/cc to me, anyway) Sort of, except that the continuation can't be used outside the function called by escape. Here's a different approach (this is essentially a variation of the recursive style, because you need to make sure the continuation is called as a tail call): let _ = let ary = [| 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12 |] in let rec loop f j = if j = 10 || ary.(j) = 5 then f () else loop f (j + 1) in let rec outer i = if i <= 1_000_000_000 then loop (fun _ -> outer (i + 1)) 0 in outer 1 This style is useful in some cases when you can write a significant part of your program using continuations. ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners