User loginNavigation |
Resume using continuationsI am looking at a way to implement Resume in a CPS-based intermediate language. Resume allows to try again a calculation with a different value. If I mark the resume value with ^retry I want to do: 1 + ^retry 8 (* 9 *) retry 5 (* 6 *) In CPS, 1 + 8 may look like: lambda (k) (k (+ 1 8)) Then I will extract the continuation around "8" to save it in a "retry" variable: lambda (k) ((lambda (n) (k (+ 1 n))) 8) lambda (k) ((lambda (k') (k' 8)) (lambda (n) (k (+ 1 n)))) (* save continuation *) lambda (k) ((lambda (k') (do ((set! retry k') (k' 8)))) (lambda (n) (k (+ 1 n)))) I could do the same transformation for an arbitrary nested variable. What I do not like is that I use a "global" variable retry which I set!, but the alternative is to pass it around as a function parameter-- not very convenient. Is my reasoning correct? Is there a better way? By Denis Bredelet -jido at 2008-04-25 16:49 | LtU Forum | previous forum topic | next forum topic | other blogs | 4439 reads
|
Browse archives
Active forum topics |
Recent comments
22 weeks 6 days ago
22 weeks 6 days ago
22 weeks 6 days ago
45 weeks 15 hours ago
49 weeks 2 days ago
50 weeks 6 days ago
50 weeks 6 days ago
1 year 1 week ago
1 year 6 weeks ago
1 year 6 weeks ago