On Sat, Feb 26, 2011 at 01:50:10PM +0100, Tomtom wrote: > Now, how should I change the code in the routine ? > > Buf if I change the routine by adding one argument to call/cc > > (define (routine cont) > (let loop ((n 10)) > (set! cont (call/cc cont n)) > (if (> n 0) > (loop (- n 1))))) > > Error: bad argument count - received 2 but expected 1: #<procedure > (call-with-current-continuation proc1295)> > > Well, I guess it's normal too, as call/cc is taking only one argument - so how > am I supposed to pass this second argument ?
You don't pass it to call/cc. Call/cc merely *captures* the continuation at that point and passes it to its lambda argument. What you want is to also pass the value to the continuation of the scheduler: (define (routine cont) (let loop ((n 10)) (display n)(newline) (set! cont (call/cc (lambda (k) (cont k n)))) (if (> n 0) (loop (- n 1))))) HTH, Peter -- http://sjamaan.ath.cx -- "The process of preparing programs for a digital computer is especially attractive, not only because it can be economically and scientifically rewarding, but also because it can be an aesthetic experience much like composing poetry or music." -- Donald Knuth _______________________________________________ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users