Hi there, I've been playing with the F-operator egg a bit. Specifically, I've made some simple tests using the %shift/%reset construction. These are the ones that avoid calling any dynamic wind thunks when calling a continuation that's not the current one or sth.
Now, does anybody have any idea why this simple example wants to eat all my memory? --- (use shift-reset) (let lp [(i 0)] (if (< i 100000000) (begin (%reset (call/cc (lambda [k] ;; uncomment the next line to see they're getting finalized ;;(set-finalizer! k (lambda [k] (print k " is being finalized"))) (if #t (dynamic-wind (lambda [] (begin)) (lambda [] (if (= 0 (remainder i 100)) (print i)) (%shift _ #f)) (lambda [] (print "out"))) (%shift _ #f))))) (lp (add1 i))))) --- If you change the #t to #f it doesn't appear to do that. It seems like the installed dw-thunks are not getting gc'd. Should they be? A related question: Should the dynamic wind thunks be called when the continuation gets gc'd? AFAIK the %reset/%shift semantics cannot be implemented in R5RS, and you cannot escape from a continuation without calling the thunks in R5RS, so this a Chicken specific question. I _think_ it would be useful if the out-thunks get called at continuation gc. I mean, if this could be implemented at all. I guess you would need to track if the out-thunk was already called or something. Currently, if you jump out of, say with-output-to-file, with %shift, and never return, you would leak file handles. Moreover, you cannot pass your function that escapes with %shift to an arbitrary function. I mean, you shouldn't. Are there other solutions to this resource leak problem other that "use shift/reset instead of %shift/%reset"? Kind regards AC _______________________________________________ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users