Browse thread
[Caml-list] Python's yield, Lisp's call-cc or C's setjmp/longjmp in OCaml
-
Nuutti Kotivuori
- Oleg Trott
-
Ville-Pertti Keinonen
- Kenneth Knowles
- Brian Hurt
[
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: | -- (:) |
| From: | Kenneth Knowles <kknowles@u...> |
| Subject: | Re: [Caml-list] Python's yield, Lisp's call-cc or C's setjmp/longjmp in OCaml |
SML/NJ is a continuation-passing style compiler, so they are trivial. It is "possible, even in the presence of native compilation exceptions," but in a traditiional call stack compilation it requires some sort of stack copying, making them extremely inefficient. (in SML/NJ every program is slower, while continuations have almost no penalty) There may be new tricks for avoiding copying of the whole stack, but I wouldn't hold your breath for continuations in ocaml. -Kenn On Tue, Dec 16, 2003 at 03:48:11PM +0200, Ville-Pertti Keinonen wrote: > > On Dec 16, 2003, at 3:13 PM, Nuutti Kotivuori wrote: > > >I am wondering, does OCaml provide any variant of being able to > >bypass the normal function call and return discipline? > > 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.). > > >And if not, what are the chances of something like that seeing the > >light of day in the future? Are there any fundamental problems in > >OCaml that would make the implementation of such a thing exceedingly > >difficult? > > 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. > > ------------------- > 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 ------------------- 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