From: Jakub Travnik Date: 2002-04-20T01:49:20+09:00 Subject: Re: Experimental language jtpl Sean Middleditch wrote: > On Fri, 2002-04-19 at 08:28, Jakub Travnik wrote: [snip] > I might just be an idiot (might? everyone asks), but I don't exactly see > what the advantage of this is, or even how it's working. ^,^ How does > the continuation know about the > writenum(10+f()+1000) > To continue printing the 1110... series? Also, what is the variable > passed to cont doing, since I don't see use of an argument or a variable > anywhere in the above expression or the f() function? To understand it better look at it in ruby. This is how ruby can do it too: ------------------------------- @cont=nil def f(ret) @cont=ret return 100 end counter=0 puts 10+callcc{|r| f(r)}+1000 counter+=1 if counter<4 @cont.call(counter) end ------------------------------- What is advantage of it is more questionable. There is programming style that uses continuations to make defined order of execution in pure functional programming languages. Continuations also offers method to switch between several running procedures explicitly, that is, cooperative multitasking. This is of course unrelated to ruby, but the virtual machine jtpl is running on is related, maybe. Happy hacking, Jakub Travnik jabber://jtra@jabber.com