callcc

call/cc in Lua - Possible?

天大地大妈咪最大 提交于 2019-11-28 18:44:56
The Wikipedia article on Continuation says: "In any language which supports closures , it is possible to write programs in continuation passing style and manually implement call/cc ." Either that is true and I need to know how to do it or it is not true and that statement needs to be corrected. If this is true, please show me how to implement call/cc in Lua because I can't see how. I think I'd be able to implement call/cc manually if Lua had the coroutine.clone function as explained here . If closures are not enough to implement call/cc then what else is needed? The text below is optional

How does the yin-yang puzzle work?

给你一囗甜甜゛ 提交于 2019-11-28 15:07:28
问题 I'm trying to grasp the semantics of call/cc in Scheme, and the Wikipedia page on continuations shows the yin-yang puzzle as an example: (let* ((yin ((lambda (cc) (display #\@) cc) (call-with-current-continuation (lambda (c) c)))) (yang ((lambda (cc) (display #\*) cc) (call-with-current-continuation (lambda (c) c)))) ) (yin yang)) It should output @*@**@***@****@... , but I don't understand why; I'd expect it to output @*@********* ... Can somebody explain in detail why the yin-yang puzzle

What is call/cc?

拥有回忆 提交于 2019-11-28 03:23:20
I've tried several times to grasp the concept of continuations and call/cc . Every single attempt was a failure. Can somebody please explain me these concepts, ideally with more realistic examples than these on Wikipedia or in other SO posts. I have background in web programming and OOP. I also understand 6502 assembly and had a minor randez-vous with Erlang. However still, I can't wrap my head around call/cc. temoto Look, i've found this Continuation Passing Style best description on this topic. Here's stripped of details copy of that article: Author: Marijn Haverbeke Date: July 24th 2007

call-with-current-continuation - state saving concept

蹲街弑〆低调 提交于 2019-11-27 22:31:37
After reading The Seasoned Schemer I felt I understood call/cc properly. But, after seeing some WOW tricks with call/cc I found I was wrong. (define cc 0) (define (f) (call/cc (lambda (k) (set! cc k) 3))) (+ 1 2 4 (f)) ; eval's to 10 (cc 13) ; eval's to 20 That perfectly match my understanding. I think when I reach a call/cc call I am just saving the program state. and calling the function next to it with a function. If that function ( k ) is called from somewhere than I just replacing the entire (call/cc ...) stuff with the parameter given to it. The above program seems to worked that way too

What is call/cc?

我与影子孤独终老i 提交于 2019-11-27 05:07:16
问题 I've tried several times to grasp the concept of continuations and call/cc. Every single attempt was a failure. Can somebody please explain me these concepts, ideally with more realistic examples than these on Wikipedia or in other SO posts. I have background in web programming and OOP. I also understand 6502 assembly and had a minor randez-vous with Erlang. However still, I can't wrap my head around call/cc. 回答1: Look, i've found this Continuation Passing Style best description on this topic

How could the new async feature in c# 5.0 be implemented with call/cc?

别来无恙 提交于 2019-11-27 03:59:24
I've been following the new announcement regarding the new async feature that will be in c# 5.0. I have a basic understanding of continuation passing style and of the transformation the new c# compiler makes to code like this snippet from Eric Lippert's post : async void ArchiveDocuments(List<Url> urls) { Task archive = null; for(int i = 0; i < urls.Count; ++i) { var document = await FetchAsync(urls[i]); if (archive != null) await archive; archive = ArchiveAsync(document); } } I know that some languages implement continuations natively, via call-with-current-continuation ( callcc ), but I don

call-with-current-continuation - state saving concept

坚强是说给别人听的谎言 提交于 2019-11-26 21:01:30
问题 After reading The Seasoned Schemer I felt I understood call/cc properly. But, after seeing some WOW tricks with call/cc I found I was wrong. (define cc 0) (define (f) (call/cc (lambda (k) (set! cc k) 3))) (+ 1 2 4 (f)) ; eval's to 10 (cc 13) ; eval's to 20 That perfectly match my understanding. I think when I reach a call/cc call I am just saving the program state. and calling the function next to it with a function. If that function ( k ) is called from somewhere than I just replacing the

How could the new async feature in c# 5.0 be implemented with call/cc?

两盒软妹~` 提交于 2019-11-26 12:40:48
问题 I\'ve been following the new announcement regarding the new async feature that will be in c# 5.0. I have a basic understanding of continuation passing style and of the transformation the new c# compiler makes to code like this snippet from Eric Lippert\'s post: async void ArchiveDocuments(List<Url> urls) { Task archive = null; for(int i = 0; i < urls.Count; ++i) { var document = await FetchAsync(urls[i]); if (archive != null) await archive; archive = ArchiveAsync(document); } } I know that

What&#39;s the difference between a continuation and a callback?

不羁的心 提交于 2019-11-26 08:39:26
问题 I\'ve been browsing all over the web in search of enlightenment about continuations, and it\'s mind boggling how the simplest of explanations can so utterly confound a JavaScript programmer like myself. This is especially true when most articles explain continuations with code in Scheme or use monads. Now that I finally think I\'ve understood the essence of continuations I wanted to know whether what I do know is actually the truth. If what I think is true is not actually true, then it\'s