<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2003/12/40790bf3984b821df7900e88d90f42ac"
  from="Dustin Sallings &lt;dustin@s...&gt;"
  author="Dustin Sallings"
  date="2003-12-16T18:10:39"
  subject="Re: [Caml-list] Python&apos;s yield, Lisp&apos;s call-cc or C&apos;s setjmp/longjmp in OCaml"
  prev="2003/12/49cb44539cd1e5dc776c6a8f345e0a04"
  next="2003/12/1156fe67188c27fdabb9039a2077419b"
  prev-in-thread="2003/12/88fc2c8210caaa7c1abe39d783755b7f"
  next-in-thread="2003/12/5d2b8084aba6efbe7ecad855a7b3fddc"
  prev-thread="2003/12/774646ec595322579ea76517edc01410"
  next-thread="2003/12/49cb44539cd1e5dc776c6a8f345e0a04"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] Python&apos;s yield, Lisp&apos;s call-cc or C&apos;s setjmp/longjmp in OCaml">
<msg 
  url="2003/12/f0d20744dca590b72fee31849f8ef5a8"
  from="Nuutti Kotivuori &lt;naked+caml@n...&gt;"
  author="Nuutti Kotivuori"
  date="2003-12-16T13:13:20"
  subject="[Caml-list] Python&apos;s yield, Lisp&apos;s call-cc or C&apos;s setjmp/longjmp in OCaml">
<msg 
  url="2003/12/bf33bfec2c564f71b03f23afcf441aca"
  from="Oleg Trott &lt;oleg_trott@c...&gt;"
  author="Oleg Trott"
  date="2003-12-16T13:28:13"
  subject="Re: [Caml-list] Python&apos;s yield, Lisp&apos;s call-cc or C&apos;s setjmp/longjmp in OCaml">
<msg 
  url="2003/12/052649193f7443e5fad49ddd9dbe05f7"
  from="Nuutti Kotivuori &lt;naked+caml@n...&gt;"
  author="Nuutti Kotivuori"
  date="2003-12-18T00:15:15"
  subject="Re: [Caml-list] Python&apos;s yield, Lisp&apos;s call-cc or C&apos;s setjmp/longjmp in OCaml">
</msg>
</msg>
<msg 
  url="2003/12/e8f2fdd8daaa77e7297afe895e600af3"
  from="Ville-Pertti Keinonen &lt;will@e...&gt;"
  author="Ville-Pertti Keinonen"
  date="2003-12-16T13:48:01"
  subject="Re: [Caml-list] Python&apos;s yield, Lisp&apos;s call-cc or C&apos;s setjmp/longjmp in OCaml">
<msg 
  url="2003/12/01e78a00f853a1ce4d39b398b9afb114"
  from="Kenneth Knowles &lt;kknowles@u...&gt;"
  author="Kenneth Knowles"
  date="2003-12-16T15:44:06"
  subject="Re: [Caml-list] Python&apos;s yield, Lisp&apos;s call-cc or C&apos;s setjmp/longjmp in OCaml">
<msg 
  url="2003/12/e9d5dc1f43b97ae6ac0b88e55734a825"
  from="Richard Jones &lt;rich@a...&gt;"
  author="Richard Jones"
  date="2003-12-16T16:45:41"
  subject="Re: [Caml-list] Python&apos;s yield, Lisp&apos;s call-cc or C&apos;s setjmp/longjmp in OCaml">
<msg 
  url="2003/12/346cf0f17cf25f0a13da2cfa8edf4234"
  from="Ville-Pertti Keinonen &lt;will@e...&gt;"
  author="Ville-Pertti Keinonen"
  date="2003-12-16T18:36:42"
  subject="Re: [Caml-list] Python&apos;s yield, Lisp&apos;s call-cc or C&apos;s setjmp/longjmp in OCaml">
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2003/12/88fc2c8210caaa7c1abe39d783755b7f"
  from="Brian Hurt &lt;bhurt@s...&gt;"
  author="Brian Hurt"
  date="2003-12-16T17:40:58"
  subject="Re: [Caml-list] Python&apos;s yield, Lisp&apos;s call-cc or C&apos;s setjmp/longjmp in OCaml">
<msg 
  url="2003/12/40790bf3984b821df7900e88d90f42ac"
  from="Dustin Sallings &lt;dustin@s...&gt;"
  author="Dustin Sallings"
  date="2003-12-16T18:10:39"
  subject="Re: [Caml-list] Python&apos;s yield, Lisp&apos;s call-cc or C&apos;s setjmp/longjmp in OCaml">
<msg 
  url="2003/12/5d2b8084aba6efbe7ecad855a7b3fddc"
  from="ijtrotts@u..."
  author="ijtrotts@u..."
  date="2003-12-17T06:29:27"
  subject="Re: [Caml-list] Python&apos;s yield, Lisp&apos;s call-cc or C&apos;s setjmp/longjmp in OCaml">
<msg 
  url="2003/12/1f4371b3bf98c5187ba2a9e7dbda1b49"
  from="Dustin Sallings &lt;dustin@s...&gt;"
  author="Dustin Sallings"
  date="2003-12-17T08:13:15"
  subject="Re: [Caml-list] Python&apos;s yield, Lisp&apos;s call-cc or C&apos;s setjmp/longjmp in OCaml">
</msg>
<msg 
  url="2003/12/850360ffe8d0d409f2af993875710c0d"
  from="Falk Hueffner &lt;falk.hueffner@s...&gt;"
  author="Falk Hueffner"
  date="2003-12-17T10:36:03"
  subject="Re: [Caml-list] Python&apos;s yield, Lisp&apos;s call-cc or C&apos;s setjmp/longjmp in OCaml">
<msg 
  url="2003/12/0d6d04a011e30722187b8606b72e19f6"
  from="Pierre Weis &lt;pierre.weis@i...&gt;"
  author="Pierre Weis"
  date="2003-12-17T19:14:30"
  subject="Re: [Caml-list] Python&apos;s yield, Lisp&apos;s call-cc or C&apos;s setjmp/longjmp in OCaml">
<msg 
  url="2003/12/8edface9abeaaa61e00ef1a62a6c512c"
  from="Falk Hueffner &lt;falk.hueffner@s...&gt;"
  author="Falk Hueffner"
  date="2003-12-17T19:32:23"
  subject="Re: [Caml-list] Python&apos;s yield, Lisp&apos;s call-cc or C&apos;s setjmp/longjmp in OCaml">
</msg>
<msg 
  url="2003/12/777e01692302f33698e7b6cb5d3e6839"
  from="David Brown &lt;caml-list@d...&gt;"
  author="David Brown"
  date="2003-12-17T20:04:11"
  subject="Re: [Caml-list] Python&apos;s yield, Lisp&apos;s call-cc or C&apos;s setjmp/longjmp in OCaml">
</msg>
<msg 
  url="2003/12/ac2f915dbdd9a3f399cc73b8be16246d"
  from="Nicolas Cannasse &lt;warplayer@f...&gt;"
  author="Nicolas Cannasse"
  date="2003-12-18T01:15:27"
  subject="Re: [Caml-list] Python&apos;s yield, Lisp&apos;s call-cc or C&apos;s setjmp/longjmp in OCaml">
<msg 
  url="2003/12/744adfd5672c3969872e3d4872e7741f"
  from="David Brown &lt;caml-list@d...&gt;"
  author="David Brown"
  date="2003-12-18T05:32:02"
  subject="Re: [Caml-list] Python&apos;s yield, Lisp&apos;s call-cc or C&apos;s setjmp/longjmp in OCaml">
</msg>
<msg 
  url="2003/12/1c4b3799107085f07200a724dd0cc444"
  from="Brian Hurt &lt;bhurt@s...&gt;"
  author="Brian Hurt"
  date="2003-12-18T06:27:21"
  subject="Re: [Caml-list] Python&apos;s yield, Lisp&apos;s call-cc or C&apos;s setjmp/longjmp in OCaml">
<msg 
  url="2003/12/4a1681fc89e77e8a070727585335ceeb"
  from="David Brown &lt;caml-list@d...&gt;"
  author="David Brown"
  date="2003-12-18T06:46:06"
  subject="Re: [Caml-list] Python&apos;s yield, Lisp&apos;s call-cc or C&apos;s setjmp/longjmp in OCaml">
</msg>
</msg>
<msg 
  url="2003/12/93c3b2ec873addb64754bf56a09fb0a7"
  from="brogoff@s..."
  author="brogoff@s..."
  date="2003-12-18T18:44:30"
  subject="Re: [Caml-list] Python&apos;s yield, Lisp&apos;s call-cc or C&apos;s setjmp/longjmp in OCaml">
</msg>
</msg>
</msg>
<msg 
  url="2003/12/f43d6ac0112ef047d18d7386d09e7f89"
  from="brogoff@s..."
  author="brogoff@s..."
  date="2003-12-17T19:43:06"
  subject="Re: [Caml-list] Python&apos;s yield, Lisp&apos;s call-cc or C&apos;s setjmp/longjmp in OCaml">
<msg 
  url="2003/12/e9e19245af4d01fc23cbaecd9a62ba86"
  from="skaller &lt;skaller@o...&gt;"
  author="skaller"
  date="2003-12-19T13:40:06"
  subject="Re: [Caml-list] Python&apos;s yield, Lisp&apos;s call-cc or C&apos;s setjmp/longjmp in OCaml">
</msg>
</msg>
</msg>
<msg 
  url="2003/12/a8c52bf4ae153acf2af4c9fccd7a479c"
  from="Nuutti Kotivuori &lt;naked+caml@n...&gt;"
  author="Nuutti Kotivuori"
  date="2003-12-18T00:51:23"
  subject="Re: [Caml-list] Python&apos;s yield, Lisp&apos;s call-cc or C&apos;s setjmp/longjmp in OCaml">
</msg>
</msg>
</msg>
</msg>
</msg>
</thread>

<contents>

On Dec 16, 2003, at 10:42, Brian Hurt wrote:

&gt; By my measurements, Ocaml's exceptions are faster than C's 
&gt; setjmp/longjmp.
&gt; Ocaml doesn't provide first-class continuations, but most of the things
&gt; people actually do with call-cc can be done in other ways in Ocaml.  I
&gt; don't know what Python's yield instruction does.

Simple example:

from __future__ import generators

def number(max):
     for i in range(max):
         if(i % 2 == 0):
             yield i, "Even"
         else:
             yield i, "Odd"

for n in number(10):
     print n

	The output of this example is as follows:

(0, 'Even')
(1, 'Odd')
(2, 'Even')
(3, 'Odd')
(4, 'Even')
(5, 'Odd')
(6, 'Even')
(7, 'Odd')
(8, 'Even')
(9, 'Odd')

	It's basically a special case of an upward continuation (or is it 
downward? I'm bad with terminology).  I think you can get pretty close 
to this behavior with streams, but it's still not as easy as a return 
statement that has a resume type thing.

-- 
Dustin Sallings

-------------------
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

</contents>

</message>

