From: Sean Middleditch Date: 2002-04-19T22:13:06+09:00 Subject: Re: Experimental language jtpl On Fri, 2002-04-19 at 08:28, Jakub Travnik wrote: > > now program that uses continuations: > > ---------------------- > > var f,cont,counter; -- variable declaration > > > > f={ > > cont=return; -- set cont to continuation of this function > > -- return is like ordinary variable it can be read > -- or written > > return(100); -- return 100 > > }; > > > > counter=0; -- set counter to zero > > writenum(10+f()+1000);-- call b and write result of addition > > > > counter=counter+1; -- increase counter > > > > if(counter<4) -- loop limited number of times > > cont(d); -- reuse continuation in cont, > > line above should be: > > cont(counter); -- reuse continuation in cont, > -- this will restart computation inside > -- addition/writenum above > > end; > > ---------------------- > > source above will print numbers: 1110, 1011, 1012, 1013 > > > > > > I hope this helps. > > 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? > > > Happy hacking, > > Jakub Travnik > jabber://jtra@jabber.com >