From: "Neil Jerram" <neiljerram@googlemail.com>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: guile-user@gnu.org
Subject: Re: `lazy-catch' and `dynamic-wind'
Date: Sun, 23 Nov 2008 21:34:05 +0000 [thread overview]
Message-ID: <49dd78620811231334i1f348223o282423adc009493@mail.gmail.com> (raw)
In-Reply-To: <87fxliicbt.fsf@gnu.org>
2008/11/23 Ludovic Courtès <ludo@gnu.org>:
> 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
next prev parent reply other threads:[~2008-11-23 21:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-23 17:25 `lazy-catch' and `dynamic-wind' Ludovic Courtès
2008-11-23 21:34 ` Neil Jerram [this message]
2008-11-23 22:56 ` Ludovic Courtès
2008-11-23 23:25 ` Neil Jerram
2008-11-24 8:43 ` Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49dd78620811231334i1f348223o282423adc009493@mail.gmail.com \
--to=neiljerram@googlemail.com \
--cc=guile-user@gnu.org \
--cc=ludo@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).