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 BAA13576; Thu, 18 Dec 2003 01:15:15 +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 BAA13623 for ; Thu, 18 Dec 2003 01:15:14 +0100 (MET) Received: from smtp2.pp.htv.fi (smtp2.pp.htv.fi [213.243.153.14]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id hBI0FDH19633 for ; Thu, 18 Dec 2003 01:15:13 +0100 (MET) Received: from posti.pp.htv.fi (posti.pp.htv.fi [212.90.64.50]) by smtp2.pp.htv.fi (Postfix) with ESMTP id 25809297350 for ; Thu, 18 Dec 2003 02:15:13 +0200 (EET) Received: from oro (aka.pp.htv.fi [213.243.183.115]) by posti.pp.htv.fi (8.11.1 (Revision 1.5+JAGae91741+JAGae92668) /8.11.1) with ESMTP id hBI0FCT14064 for ; Thu, 18 Dec 2003 02:15:12 +0200 (EET) Received: from naked by oro with local (Exim 3.36 #1 (Debian)) id 1AWlou-0002Oj-00 for ; Thu, 18 Dec 2003 02:15:12 +0200 To: caml-list@inria.fr Subject: Re: [Caml-list] Python's yield, Lisp's call-cc or C's setjmp/longjmp in OCaml References: <87n09sucr9.fsf@naked.iki.fi> From: Nuutti Kotivuori Date: Thu, 18 Dec 2003 02:15:11 +0200 In-Reply-To: <200312160828.02480.oleg_trott@columbia.edu> (Oleg Trott's message of "Tue, 16 Dec 2003 08:28:02 -0500") Message-ID: <87d6anrng0.fsf@naked.iki.fi> User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Portable Code, linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 python's:01 lisp's:01 c's:01 oleg:01 coroutines:01 model:01 ocaml's:01 c's:01 python's:01 suspend:01 suspending:01 ocaml:01 ocaml:01 caml:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk I've lumped together a bunch of answers to not spam the list too much. Oleg Trott wrote: > call/cc is Scheme, Common Lisp has "throw" instead, and ML has > "raise". Thanks for the reply, but I was aware that OCaml has exceptions. Seth J. Fogarty wrote: > Um.... does lisp have call/cc, I thought that was only scheme? But > in any case, look at exceptions. They provide a very similar control > flow arrangement to continuations (although they are weaker). Thanks. Ville-Pertti Keinonen wrote: > There are many different things you could be referring to, some of > which OCaml does have (exceptions), some of which it doesn't > (coroutines, first-class continuations, generators etc.). Well, indeed it was the three latter examples you gave that I was looking for. > First-class, capturable continuations are one of the things I often > wish OCaml had, but implementing them efficiently would require > significant changes to the execution model. > > SML/NJ has efficient first-class continuations, so it's clearly > possible, even in the presence of native compilation and exceptions. That's nice to know! Yes, I'd wish for capturable continuations as well - but living without them is certainly possible. Brian Hurt wrote: > By my measurements, Ocaml's exceptions are faster than C's > setjmp/longjmp. Ocaml doesn't provide first-class continuations, > but most of the things people actually do with call-cc can be done > in other ways in Ocaml. I don't know what Python's yield > instruction does. Ah yes, I should have been more specific. I was looking for things that are possible with first-class continuations - but also something weaker, as Python's yield. > What do you want to do? Well, what I was looking for is a way to suspend the execution of something, and come back to it later. Exceptions provide me a way from getting out of odd places, but not a way back in those odd places. Python's yield is just a limited form of suspending executing something, and continuing it later. -- Naked ------------------- 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