Browse thread
[Caml-list] Python's yield, Lisp's call-cc or C's setjmp/longjmp in OCaml
-
Nuutti Kotivuori
-
Oleg Trott
- Nuutti Kotivuori
- Ville-Pertti Keinonen
- Brian Hurt
-
Oleg Trott
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2003-12-18 (00:15) |
From: | Nuutti Kotivuori <naked+caml@n...> |
Subject: | Re: [Caml-list] Python's yield, Lisp's call-cc or C's setjmp/longjmp in OCaml |
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