2008/11/23 Ludovic Courtès <[EMAIL PROTECTED]>: > Hello Guilers! > > I noticed the following subtle difference between fluids and SRFI-39 > parameters when accessed from a `lazy-catch' handler: > > (define fl (make-fluid)) > (fluid-set! fl 'outside) > > (lazy-catch #t > (lambda () > (fluid-set! fl 'inside) > (throw 'foobar)) > (lambda (key . args) > (format #t "fluid = ~A~%" (fluid-ref fl)) > (exit 1))) > > => PRINTS: fluid = inside
This is as expected. Note that there is nothing like dynamic-wind inside fluid-set! Did you perhaps mean with-fluids instead? If you used with-fluids, I would expect the same behaviour as you've described for parameterize. > ... compared to: > > (use-modules (srfi srfi-39)) > > (define fl (make-parameter 'outside)) > > (lazy-catch #t > (lambda () > (parameterize ((fl 'inside)) > (throw 'foobar))) > (lambda (key . args) > (format #t "fluid = ~A~%" (fl)) > (exit 1))) > > => PRINTS: fluid = outside > > This comes from the fact that `parameterize' sets up a `dynamic-wind' > whose unwinder is called *before* the `lazy-catch' handler. I find it a > bit counter-intuitive since the `lazy-catch' is documented as follows: > > This behaves exactly like `catch', except that it does not unwind > the stack before invoking HANDLER. That text is misleading and should be improved. See the manual section [1] for the whole story, which explains that it is actually only the call stack that is not unwound. [1] http://www.gnu.org/software/guile/manual/html_node/Lazy-Catch.html#Lazy-Catch This is why I invented with-throw-handler and the optional pre-unwind-handler parameter of `catch'. Perhaps you need to use one of those instead. Regards, Neil