This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

dynamic-wind


A colleague asked me the followign about dynamic-wind:

  Will IN-GUARD and OUT-GUARD be called precisely the same number of
  times?

I think the answer is yes, but if anybody has a definitive insight
into this, it would be good.

The reference manual says:

     IN-GUARD is called, then THUNK, then OUT-GUARD.

     If, any time during the execution of THUNK, the continuation of
     the `dynamic-wind' expression is escaped non-locally, OUT-GUARD is
     called.   If the continuation of the dynamic-wind is re-entered,
     IN-GUARD is called.   Thus IN-GUARD and OUT-GUARD may be called
     any number of times.

My rationale for the yes is as follows:

If we have a non-local escape, OUT-GUARD is called once. If it is to
be called again, we need to enter the continuation again, in which
case IN-GUARD will be called again.


---------------------------+--------------------------------------------------
Christian Lynbech          | Telebit Communications A/S                       
Fax:   +45 8628 8186       | Fabrik 11, DK-8260 Viby J
Phone: +45 8628 8177 + 28  | email: chl@tbit.dk --- URL: http://www.telebit.dk
---------------------------+--------------------------------------------------
Hit the philistines three times over the head with the Elisp reference manual.
                                        - petonic@hal.com (Michael A. Petonic)