6 ms·
Could someone explain how the 'call/cc in javascript' from the article is supposed to be used? function callcc (f,cc) { f(function(x,k) { cc(x) },cc);
by ajro 16y ago
Could someone explain how the 'call/cc in javascript' from the article is supposed to be used?
function callcc (f,cc) {
f(function(x,k) { cc(x) },cc);
}
- mattmight 16y agoSuppose you wrote a compiler that translates to JavaScript in continuation-passing style. (Or suppose you wrote all your JavaScript in continuation-passing style.) That's the implementation of call/cc. For how to use call/cc, I recommend my other article on continuations: http://matt.might.net/articles/programming-with-continuations--exceptions-backtracking-search-threads-generators-coroutines/ http://matt.might.net/articles/programming-with-continuation...
- ajro 16y agoI found this link before posting the question but I still can't imagine how to use javascript call/cc implementation from your article (on the other hand I think I know how to use call/cc in scheme). Maybe I am too tired today. If you posted a simple example of JavaScript written in continuation-passing style and using this call/cc implementation probably everything would be clear.